@medialane/sdk 0.78.0 → 0.79.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 +63 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -1
- package/dist/index.d.ts +46 -1
- package/dist/index.js +61 -1
- package/dist/index.js.map +1 -1
- package/dist/starknet/index.cjs.map +1 -1
- package/dist/starknet/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -472,6 +472,8 @@ declare function stringifyBigInts(obj: unknown): unknown;
|
|
|
472
472
|
* Convert a u256 represented as { low: string; high: string } to a single BigInt.
|
|
473
473
|
*/
|
|
474
474
|
declare function u256ToBigInt(low: string, high: string): bigint;
|
|
475
|
+
/** Split a bigint into low/high felt252 halves for a Cairo u256 (inverse of `u256ToBigInt`). */
|
|
476
|
+
declare function encodeU256(n: bigint): [string, string];
|
|
475
477
|
|
|
476
478
|
/**
|
|
477
479
|
* Resilient Starknet RPC helpers — the single source of truth for "what counts
|
|
@@ -533,4 +535,47 @@ interface FailoverFetchOptions {
|
|
|
533
535
|
*/
|
|
534
536
|
declare function createFailoverFetch(urls: string[], options?: FailoverFetchOptions): typeof fetch;
|
|
535
537
|
|
|
536
|
-
|
|
538
|
+
/**
|
|
539
|
+
* Shared OpenSea-ERC721 + Berne-Convention metadata builder.
|
|
540
|
+
*
|
|
541
|
+
* Single source of truth for how a Medialane asset's metadata JSON is shaped.
|
|
542
|
+
* Pure function — no network calls, no FormData. Server-safe and chain-neutral.
|
|
543
|
+
*/
|
|
544
|
+
type AssetAttribute = {
|
|
545
|
+
trait_type: string;
|
|
546
|
+
value: string;
|
|
547
|
+
};
|
|
548
|
+
interface AssetMetadata {
|
|
549
|
+
name: string;
|
|
550
|
+
description: string;
|
|
551
|
+
image: string | null;
|
|
552
|
+
external_url: string;
|
|
553
|
+
attributes: AssetAttribute[];
|
|
554
|
+
}
|
|
555
|
+
interface BuildAssetMetadataInput {
|
|
556
|
+
name: string;
|
|
557
|
+
description?: string | null;
|
|
558
|
+
externalUrl?: string | null;
|
|
559
|
+
imageUri?: string | null;
|
|
560
|
+
creator?: string | null;
|
|
561
|
+
ipType?: string | null;
|
|
562
|
+
licenseType?: string | null;
|
|
563
|
+
commercialUse?: string | null;
|
|
564
|
+
derivatives?: string | null;
|
|
565
|
+
attribution?: string | null;
|
|
566
|
+
geographicScope?: string | null;
|
|
567
|
+
aiPolicy?: string | null;
|
|
568
|
+
royalty?: string | null;
|
|
569
|
+
edition?: string | null;
|
|
570
|
+
/** Already-extracted `tmpl_*` template/custom traits (reserved names are filtered here). */
|
|
571
|
+
templateTraits?: {
|
|
572
|
+
traitType: string;
|
|
573
|
+
value: string;
|
|
574
|
+
}[];
|
|
575
|
+
/** ISO date (YYYY-MM-DD) stamped as the Berne registration trait. Defaults to today. */
|
|
576
|
+
registrationDate?: string;
|
|
577
|
+
}
|
|
578
|
+
declare const RESERVED_TRAITS: Set<string>;
|
|
579
|
+
declare function buildAssetMetadata(input: BuildAssetMetadataInput): AssetMetadata;
|
|
580
|
+
|
|
581
|
+
export { type AssetAttribute, type AssetMetadata, type BuildAssetMetadataInput, Chain, DEFAULT_CURRENCY, type FailoverFetchOptions, PUBLIC_RPC_FALLBACKS, RESERVED_TRAITS, STARKNET_COLLECTION_1155_CLASS_HASH, STARKNET_COLLECTION_1155_CONTRACT, STARKNET_COLLECTION_1155_FACTORY_CLASS_HASH, STARKNET_COLLECTION_1155_START_BLOCK, STARKNET_COLLECTION_721_CONTRACT, STARKNET_COLLECTION_721_START_BLOCK, STARKNET_CREATOR_COIN_CLASS_HASH, STARKNET_CREATOR_COIN_EKUBO_LAUNCHER, STARKNET_CREATOR_COIN_FACTORY_CLASS_HASH, STARKNET_CREATOR_COIN_FACTORY_CONTRACT, STARKNET_CREATOR_COIN_START_BLOCK, STARKNET_DROP_COLLECTION_CLASS_HASH, STARKNET_DROP_FACTORY_CONTRACT, STARKNET_EKUBO_CORE, STARKNET_IPCOLLECTION_CLASS_HASH, STARKNET_IPNFT_CLASS_HASH, STARKNET_IP_CLUB_COLLECTION_CLASS_HASH, STARKNET_IP_CLUB_FACTORY_CONTRACT, STARKNET_IP_SPONSORSHIP_CLASS_HASH, STARKNET_IP_SPONSORSHIP_CONTRACT, STARKNET_IP_TICKETS_FACTORY_CONTRACT, STARKNET_IP_TICKET_COLLECTION_CLASS_HASH, STARKNET_MARKETPLACE_1155_CLASS_HASH, STARKNET_MARKETPLACE_1155_CONTRACT, STARKNET_MARKETPLACE_1155_START_BLOCK, STARKNET_MARKETPLACE_721_CLASS_HASH, STARKNET_MARKETPLACE_721_CONTRACT, STARKNET_MARKETPLACE_721_START_BLOCK, STARKNET_NFTCOMMENTS_CONTRACT, STARKNET_POP_COLLECTION_CLASS_HASH, STARKNET_POP_FACTORY_CONTRACT, SUPPORTED_TOKENS, SUPPORTED_URL_CHAINS, ServiceCapability, ServiceDefinition, type ServiceId, type SupportedToken, type SupportedTokenSymbol, assetHref, buildAssetMetadata, chainFromSlug, chainSlug, coinHref, collectionHref, createFailoverFetch, encodeU256, formatAmount, getListableTokens, getService, getServicesByCapability, getTokenByAddress, getTokenBySymbol, hasCapability, isServiceId, isTransientRpcError, listServices, normalizeAddress, normalizeHash, parseAmount, shortenAddress, stringifyBigInts, u256ToBigInt };
|
package/dist/index.d.ts
CHANGED
|
@@ -472,6 +472,8 @@ declare function stringifyBigInts(obj: unknown): unknown;
|
|
|
472
472
|
* Convert a u256 represented as { low: string; high: string } to a single BigInt.
|
|
473
473
|
*/
|
|
474
474
|
declare function u256ToBigInt(low: string, high: string): bigint;
|
|
475
|
+
/** Split a bigint into low/high felt252 halves for a Cairo u256 (inverse of `u256ToBigInt`). */
|
|
476
|
+
declare function encodeU256(n: bigint): [string, string];
|
|
475
477
|
|
|
476
478
|
/**
|
|
477
479
|
* Resilient Starknet RPC helpers — the single source of truth for "what counts
|
|
@@ -533,4 +535,47 @@ interface FailoverFetchOptions {
|
|
|
533
535
|
*/
|
|
534
536
|
declare function createFailoverFetch(urls: string[], options?: FailoverFetchOptions): typeof fetch;
|
|
535
537
|
|
|
536
|
-
|
|
538
|
+
/**
|
|
539
|
+
* Shared OpenSea-ERC721 + Berne-Convention metadata builder.
|
|
540
|
+
*
|
|
541
|
+
* Single source of truth for how a Medialane asset's metadata JSON is shaped.
|
|
542
|
+
* Pure function — no network calls, no FormData. Server-safe and chain-neutral.
|
|
543
|
+
*/
|
|
544
|
+
type AssetAttribute = {
|
|
545
|
+
trait_type: string;
|
|
546
|
+
value: string;
|
|
547
|
+
};
|
|
548
|
+
interface AssetMetadata {
|
|
549
|
+
name: string;
|
|
550
|
+
description: string;
|
|
551
|
+
image: string | null;
|
|
552
|
+
external_url: string;
|
|
553
|
+
attributes: AssetAttribute[];
|
|
554
|
+
}
|
|
555
|
+
interface BuildAssetMetadataInput {
|
|
556
|
+
name: string;
|
|
557
|
+
description?: string | null;
|
|
558
|
+
externalUrl?: string | null;
|
|
559
|
+
imageUri?: string | null;
|
|
560
|
+
creator?: string | null;
|
|
561
|
+
ipType?: string | null;
|
|
562
|
+
licenseType?: string | null;
|
|
563
|
+
commercialUse?: string | null;
|
|
564
|
+
derivatives?: string | null;
|
|
565
|
+
attribution?: string | null;
|
|
566
|
+
geographicScope?: string | null;
|
|
567
|
+
aiPolicy?: string | null;
|
|
568
|
+
royalty?: string | null;
|
|
569
|
+
edition?: string | null;
|
|
570
|
+
/** Already-extracted `tmpl_*` template/custom traits (reserved names are filtered here). */
|
|
571
|
+
templateTraits?: {
|
|
572
|
+
traitType: string;
|
|
573
|
+
value: string;
|
|
574
|
+
}[];
|
|
575
|
+
/** ISO date (YYYY-MM-DD) stamped as the Berne registration trait. Defaults to today. */
|
|
576
|
+
registrationDate?: string;
|
|
577
|
+
}
|
|
578
|
+
declare const RESERVED_TRAITS: Set<string>;
|
|
579
|
+
declare function buildAssetMetadata(input: BuildAssetMetadataInput): AssetMetadata;
|
|
580
|
+
|
|
581
|
+
export { type AssetAttribute, type AssetMetadata, type BuildAssetMetadataInput, Chain, DEFAULT_CURRENCY, type FailoverFetchOptions, PUBLIC_RPC_FALLBACKS, RESERVED_TRAITS, STARKNET_COLLECTION_1155_CLASS_HASH, STARKNET_COLLECTION_1155_CONTRACT, STARKNET_COLLECTION_1155_FACTORY_CLASS_HASH, STARKNET_COLLECTION_1155_START_BLOCK, STARKNET_COLLECTION_721_CONTRACT, STARKNET_COLLECTION_721_START_BLOCK, STARKNET_CREATOR_COIN_CLASS_HASH, STARKNET_CREATOR_COIN_EKUBO_LAUNCHER, STARKNET_CREATOR_COIN_FACTORY_CLASS_HASH, STARKNET_CREATOR_COIN_FACTORY_CONTRACT, STARKNET_CREATOR_COIN_START_BLOCK, STARKNET_DROP_COLLECTION_CLASS_HASH, STARKNET_DROP_FACTORY_CONTRACT, STARKNET_EKUBO_CORE, STARKNET_IPCOLLECTION_CLASS_HASH, STARKNET_IPNFT_CLASS_HASH, STARKNET_IP_CLUB_COLLECTION_CLASS_HASH, STARKNET_IP_CLUB_FACTORY_CONTRACT, STARKNET_IP_SPONSORSHIP_CLASS_HASH, STARKNET_IP_SPONSORSHIP_CONTRACT, STARKNET_IP_TICKETS_FACTORY_CONTRACT, STARKNET_IP_TICKET_COLLECTION_CLASS_HASH, STARKNET_MARKETPLACE_1155_CLASS_HASH, STARKNET_MARKETPLACE_1155_CONTRACT, STARKNET_MARKETPLACE_1155_START_BLOCK, STARKNET_MARKETPLACE_721_CLASS_HASH, STARKNET_MARKETPLACE_721_CONTRACT, STARKNET_MARKETPLACE_721_START_BLOCK, STARKNET_NFTCOMMENTS_CONTRACT, STARKNET_POP_COLLECTION_CLASS_HASH, STARKNET_POP_FACTORY_CONTRACT, SUPPORTED_TOKENS, SUPPORTED_URL_CHAINS, ServiceCapability, ServiceDefinition, type ServiceId, type SupportedToken, type SupportedTokenSymbol, assetHref, buildAssetMetadata, chainFromSlug, chainSlug, coinHref, collectionHref, createFailoverFetch, encodeU256, formatAmount, getListableTokens, getService, getServicesByCapability, getTokenByAddress, getTokenBySymbol, hasCapability, isServiceId, isTransientRpcError, listServices, normalizeAddress, normalizeHash, parseAmount, shortenAddress, stringifyBigInts, u256ToBigInt };
|
package/dist/index.js
CHANGED
|
@@ -1303,6 +1303,12 @@ function stringifyBigInts(obj) {
|
|
|
1303
1303
|
function u256ToBigInt(low, high) {
|
|
1304
1304
|
return BigInt(low) + (BigInt(high) << 128n);
|
|
1305
1305
|
}
|
|
1306
|
+
function encodeU256(n) {
|
|
1307
|
+
return [
|
|
1308
|
+
(n & 0xffffffffffffffffffffffffffffffffn).toString(),
|
|
1309
|
+
(n >> 128n).toString()
|
|
1310
|
+
];
|
|
1311
|
+
}
|
|
1306
1312
|
|
|
1307
1313
|
// src/utils/rpc.ts
|
|
1308
1314
|
var PUBLIC_RPC_FALLBACKS = [
|
|
@@ -1357,6 +1363,60 @@ function createFailoverFetch(urls, options = {}) {
|
|
|
1357
1363
|
return failover;
|
|
1358
1364
|
}
|
|
1359
1365
|
|
|
1360
|
-
|
|
1366
|
+
// src/metadata.ts
|
|
1367
|
+
var RESERVED_TRAITS = /* @__PURE__ */ new Set([
|
|
1368
|
+
"Creator",
|
|
1369
|
+
"IP Type",
|
|
1370
|
+
"License",
|
|
1371
|
+
"Commercial Use",
|
|
1372
|
+
"Derivatives",
|
|
1373
|
+
"Attribution",
|
|
1374
|
+
"Territory",
|
|
1375
|
+
"AI Policy",
|
|
1376
|
+
"Royalty",
|
|
1377
|
+
"Edition",
|
|
1378
|
+
"Standard",
|
|
1379
|
+
"Registration"
|
|
1380
|
+
]);
|
|
1381
|
+
var RESERVED_TRAITS_NORMALIZED = new Set([...RESERVED_TRAITS].map((t) => t.toLowerCase()));
|
|
1382
|
+
function buildAssetMetadata(input) {
|
|
1383
|
+
const attributes = [];
|
|
1384
|
+
if (input.creator) attributes.push({ trait_type: "Creator", value: input.creator });
|
|
1385
|
+
if (input.ipType) attributes.push({ trait_type: "IP Type", value: input.ipType });
|
|
1386
|
+
if (input.licenseType) attributes.push({ trait_type: "License", value: input.licenseType });
|
|
1387
|
+
if (input.commercialUse) attributes.push({ trait_type: "Commercial Use", value: input.commercialUse });
|
|
1388
|
+
if (input.derivatives) attributes.push({ trait_type: "Derivatives", value: input.derivatives });
|
|
1389
|
+
if (input.attribution) attributes.push({ trait_type: "Attribution", value: input.attribution });
|
|
1390
|
+
if (input.geographicScope) attributes.push({ trait_type: "Territory", value: input.geographicScope });
|
|
1391
|
+
if (input.aiPolicy) attributes.push({ trait_type: "AI Policy", value: input.aiPolicy });
|
|
1392
|
+
if (input.royalty) {
|
|
1393
|
+
const num = parseFloat(String(input.royalty).replace("%", ""));
|
|
1394
|
+
if (!isNaN(num) && num > 0) attributes.push({ trait_type: "Royalty", value: `${num}%` });
|
|
1395
|
+
}
|
|
1396
|
+
if (input.edition) attributes.push({ trait_type: "Edition", value: input.edition });
|
|
1397
|
+
for (const t of input.templateTraits ?? []) {
|
|
1398
|
+
const traitType = t.traitType?.trim() ?? "";
|
|
1399
|
+
const traitValue = String(t.value ?? "").trim();
|
|
1400
|
+
if (!traitType || !traitValue || RESERVED_TRAITS_NORMALIZED.has(traitType.toLowerCase())) continue;
|
|
1401
|
+
if (traitType.length > 64 || traitValue.length > 512) continue;
|
|
1402
|
+
attributes.push({ trait_type: traitType, value: traitValue });
|
|
1403
|
+
}
|
|
1404
|
+
if (input.licenseType) {
|
|
1405
|
+
attributes.push({ trait_type: "Standard", value: "Berne Convention" });
|
|
1406
|
+
attributes.push({
|
|
1407
|
+
trait_type: "Registration",
|
|
1408
|
+
value: input.registrationDate ?? (/* @__PURE__ */ new Date()).toISOString().split("T")[0]
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
return {
|
|
1412
|
+
name: input.name,
|
|
1413
|
+
description: input.description ?? "",
|
|
1414
|
+
image: input.imageUri ?? null,
|
|
1415
|
+
external_url: input.externalUrl || "https://medialane.io",
|
|
1416
|
+
attributes
|
|
1417
|
+
};
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
export { ApiClient, CHAINS, DEFAULT_CHAIN, DEFAULT_CURRENCY, FeeConfigSchema, MedialaneApiError, OPEN_LICENSES, PUBLIC_RPC_FALLBACKS, RESERVED_TRAITS, STARKNET_COLLECTION_1155_CLASS_HASH, STARKNET_COLLECTION_1155_CONTRACT, STARKNET_COLLECTION_1155_FACTORY_CLASS_HASH, STARKNET_COLLECTION_1155_START_BLOCK, STARKNET_COLLECTION_721_CONTRACT, STARKNET_COLLECTION_721_START_BLOCK, STARKNET_CREATOR_COIN_CLASS_HASH, STARKNET_CREATOR_COIN_EKUBO_LAUNCHER, STARKNET_CREATOR_COIN_FACTORY_CLASS_HASH, STARKNET_CREATOR_COIN_FACTORY_CONTRACT, STARKNET_CREATOR_COIN_START_BLOCK, STARKNET_DROP_COLLECTION_CLASS_HASH, STARKNET_DROP_FACTORY_CONTRACT, STARKNET_EKUBO_CORE, STARKNET_IPCOLLECTION_CLASS_HASH, STARKNET_IPNFT_CLASS_HASH, STARKNET_IP_CLUB_COLLECTION_CLASS_HASH, STARKNET_IP_CLUB_FACTORY_CONTRACT, STARKNET_IP_SPONSORSHIP_CLASS_HASH, STARKNET_IP_SPONSORSHIP_CONTRACT, STARKNET_IP_TICKETS_FACTORY_CONTRACT, STARKNET_IP_TICKET_COLLECTION_CLASS_HASH, STARKNET_MARKETPLACE_1155_CLASS_HASH, STARKNET_MARKETPLACE_1155_CONTRACT, STARKNET_MARKETPLACE_1155_START_BLOCK, STARKNET_MARKETPLACE_721_CLASS_HASH, STARKNET_MARKETPLACE_721_CONTRACT, STARKNET_MARKETPLACE_721_START_BLOCK, STARKNET_NFTCOMMENTS_CONTRACT, STARKNET_POP_COLLECTION_CLASS_HASH, STARKNET_POP_FACTORY_CONTRACT, SUPPORTED_TOKENS, SUPPORTED_URL_CHAINS, assetHref, buildAssetMetadata, chainFromSlug, chainSlug, coinHref, collectionHref, createFailoverFetch, encodeU256, formatAmount, getCoordinates, getListableTokens, getService, getServicesByCapability, getStarknetCoordinates, getTokenByAddress, getTokenBySymbol, hasCapability, isServiceId, isTransientRpcError, listServices, normalizeAddress, normalizeHash, parseAmount, resolveConfig, resolveFeeConfig, shortenAddress, stringifyBigInts, u256ToBigInt };
|
|
1361
1421
|
//# sourceMappingURL=index.js.map
|
|
1362
1422
|
//# sourceMappingURL=index.js.map
|