@medialane/sdk 0.78.0 → 0.80.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 CHANGED
@@ -445,6 +445,9 @@ var ApiClient = class {
445
445
  createCancelIntent(params) {
446
446
  return this.post("/v1/intents/cancel", params);
447
447
  }
448
+ createCheckoutIntent(params) {
449
+ return this.post("/v1/intents/checkout", params);
450
+ }
448
451
  getIntent(id) {
449
452
  return this.get(`/v1/intents/${id}`);
450
453
  }
@@ -460,6 +463,9 @@ var ApiClient = class {
460
463
  createCollectionIntent(params) {
461
464
  return this.post("/v1/intents/create-collection", params);
462
465
  }
466
+ createTierIntent(params) {
467
+ return this.post("/v1/intents/create-tier", params);
468
+ }
463
469
  /**
464
470
  * Create a counter-offer intent. The seller proposes a new price in response
465
471
  * to a buyer's active bid. clerkToken is optional — the endpoint authenticates
@@ -1305,6 +1311,12 @@ function stringifyBigInts(obj) {
1305
1311
  function u256ToBigInt(low, high) {
1306
1312
  return BigInt(low) + (BigInt(high) << 128n);
1307
1313
  }
1314
+ function encodeU256(n) {
1315
+ return [
1316
+ (n & 0xffffffffffffffffffffffffffffffffn).toString(),
1317
+ (n >> 128n).toString()
1318
+ ];
1319
+ }
1308
1320
 
1309
1321
  // src/utils/rpc.ts
1310
1322
  var PUBLIC_RPC_FALLBACKS = [
@@ -1359,6 +1371,60 @@ function createFailoverFetch(urls, options = {}) {
1359
1371
  return failover;
1360
1372
  }
1361
1373
 
1374
+ // src/metadata.ts
1375
+ var RESERVED_TRAITS = /* @__PURE__ */ new Set([
1376
+ "Creator",
1377
+ "IP Type",
1378
+ "License",
1379
+ "Commercial Use",
1380
+ "Derivatives",
1381
+ "Attribution",
1382
+ "Territory",
1383
+ "AI Policy",
1384
+ "Royalty",
1385
+ "Edition",
1386
+ "Standard",
1387
+ "Registration"
1388
+ ]);
1389
+ var RESERVED_TRAITS_NORMALIZED = new Set([...RESERVED_TRAITS].map((t) => t.toLowerCase()));
1390
+ function buildAssetMetadata(input) {
1391
+ const attributes = [];
1392
+ if (input.creator) attributes.push({ trait_type: "Creator", value: input.creator });
1393
+ if (input.ipType) attributes.push({ trait_type: "IP Type", value: input.ipType });
1394
+ if (input.licenseType) attributes.push({ trait_type: "License", value: input.licenseType });
1395
+ if (input.commercialUse) attributes.push({ trait_type: "Commercial Use", value: input.commercialUse });
1396
+ if (input.derivatives) attributes.push({ trait_type: "Derivatives", value: input.derivatives });
1397
+ if (input.attribution) attributes.push({ trait_type: "Attribution", value: input.attribution });
1398
+ if (input.geographicScope) attributes.push({ trait_type: "Territory", value: input.geographicScope });
1399
+ if (input.aiPolicy) attributes.push({ trait_type: "AI Policy", value: input.aiPolicy });
1400
+ if (input.royalty) {
1401
+ const num = parseFloat(String(input.royalty).replace("%", ""));
1402
+ if (!isNaN(num) && num > 0) attributes.push({ trait_type: "Royalty", value: `${num}%` });
1403
+ }
1404
+ if (input.edition) attributes.push({ trait_type: "Edition", value: input.edition });
1405
+ for (const t of input.templateTraits ?? []) {
1406
+ const traitType = t.traitType?.trim() ?? "";
1407
+ const traitValue = String(t.value ?? "").trim();
1408
+ if (!traitType || !traitValue || RESERVED_TRAITS_NORMALIZED.has(traitType.toLowerCase())) continue;
1409
+ if (traitType.length > 64 || traitValue.length > 512) continue;
1410
+ attributes.push({ trait_type: traitType, value: traitValue });
1411
+ }
1412
+ if (input.licenseType) {
1413
+ attributes.push({ trait_type: "Standard", value: "Berne Convention" });
1414
+ attributes.push({
1415
+ trait_type: "Registration",
1416
+ value: input.registrationDate ?? (/* @__PURE__ */ new Date()).toISOString().split("T")[0]
1417
+ });
1418
+ }
1419
+ return {
1420
+ name: input.name,
1421
+ description: input.description ?? "",
1422
+ image: input.imageUri ?? null,
1423
+ external_url: input.externalUrl || "https://medialane.io",
1424
+ attributes
1425
+ };
1426
+ }
1427
+
1362
1428
  exports.ApiClient = ApiClient;
1363
1429
  exports.CHAINS = CHAINS;
1364
1430
  exports.DEFAULT_CHAIN = DEFAULT_CHAIN;
@@ -1367,6 +1433,7 @@ exports.FeeConfigSchema = FeeConfigSchema;
1367
1433
  exports.MedialaneApiError = MedialaneApiError;
1368
1434
  exports.OPEN_LICENSES = OPEN_LICENSES;
1369
1435
  exports.PUBLIC_RPC_FALLBACKS = PUBLIC_RPC_FALLBACKS;
1436
+ exports.RESERVED_TRAITS = RESERVED_TRAITS;
1370
1437
  exports.STARKNET_COLLECTION_1155_CLASS_HASH = STARKNET_COLLECTION_1155_CLASS_HASH;
1371
1438
  exports.STARKNET_COLLECTION_1155_CONTRACT = STARKNET_COLLECTION_1155_CONTRACT;
1372
1439
  exports.STARKNET_COLLECTION_1155_FACTORY_CLASS_HASH = STARKNET_COLLECTION_1155_FACTORY_CLASS_HASH;
@@ -1401,11 +1468,13 @@ exports.STARKNET_POP_FACTORY_CONTRACT = STARKNET_POP_FACTORY_CONTRACT;
1401
1468
  exports.SUPPORTED_TOKENS = SUPPORTED_TOKENS;
1402
1469
  exports.SUPPORTED_URL_CHAINS = SUPPORTED_URL_CHAINS;
1403
1470
  exports.assetHref = assetHref;
1471
+ exports.buildAssetMetadata = buildAssetMetadata;
1404
1472
  exports.chainFromSlug = chainFromSlug;
1405
1473
  exports.chainSlug = chainSlug;
1406
1474
  exports.coinHref = coinHref;
1407
1475
  exports.collectionHref = collectionHref;
1408
1476
  exports.createFailoverFetch = createFailoverFetch;
1477
+ exports.encodeU256 = encodeU256;
1409
1478
  exports.formatAmount = formatAmount;
1410
1479
  exports.getCoordinates = getCoordinates;
1411
1480
  exports.getListableTokens = getListableTokens;