@medialane/ui 0.391.0 → 0.393.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/components/account/input-otp.d.cts +2 -2
- package/dist/components/account/input-otp.d.ts +2 -2
- package/dist/components/button.d.cts +1 -1
- package/dist/components/button.d.ts +1 -1
- package/dist/components/create-form-primitives.cjs +6 -1
- package/dist/components/create-form-primitives.cjs.map +1 -1
- package/dist/components/create-form-primitives.js +6 -1
- package/dist/components/create-form-primitives.js.map +1 -1
- package/dist/components/drop/create/asset-editor.cjs +164 -0
- package/dist/components/drop/create/asset-editor.cjs.map +1 -0
- package/dist/components/drop/create/asset-editor.d.cts +17 -0
- package/dist/components/drop/create/asset-editor.d.ts +17 -0
- package/dist/components/drop/create/asset-editor.js +140 -0
- package/dist/components/drop/create/asset-editor.js.map +1 -0
- package/dist/components/drop/create/assets-panel.cjs +269 -0
- package/dist/components/drop/create/assets-panel.cjs.map +1 -0
- package/dist/components/drop/create/assets-panel.d.cts +11 -0
- package/dist/components/drop/create/assets-panel.d.ts +11 -0
- package/dist/components/drop/create/assets-panel.js +245 -0
- package/dist/components/drop/create/assets-panel.js.map +1 -0
- package/dist/components/drop/create/collection-panel.cjs +138 -0
- package/dist/components/drop/create/collection-panel.cjs.map +1 -0
- package/dist/components/drop/create/collection-panel.d.cts +12 -0
- package/dist/components/drop/create/collection-panel.d.ts +12 -0
- package/dist/components/drop/create/collection-panel.js +113 -0
- package/dist/components/drop/create/collection-panel.js.map +1 -0
- package/dist/components/drop/create/drop-create.cjs +57 -112
- package/dist/components/drop/create/drop-create.cjs.map +1 -1
- package/dist/components/drop/create/drop-create.d.cts +6 -12
- package/dist/components/drop/create/drop-create.d.ts +6 -12
- package/dist/components/drop/create/drop-create.js +60 -112
- package/dist/components/drop/create/drop-create.js.map +1 -1
- package/dist/components/drop/create/drop-fields.cjs +40 -144
- package/dist/components/drop/create/drop-fields.cjs.map +1 -1
- package/dist/components/drop/create/drop-fields.d.cts +5 -17
- package/dist/components/drop/create/drop-fields.d.ts +5 -17
- package/dist/components/drop/create/drop-fields.js +40 -131
- package/dist/components/drop/create/drop-fields.js.map +1 -1
- package/dist/components/drop/create/drop-panel.cjs +57 -0
- package/dist/components/drop/create/drop-panel.cjs.map +1 -0
- package/dist/components/drop/create/drop-panel.d.cts +25 -0
- package/dist/components/drop/create/drop-panel.d.ts +25 -0
- package/dist/components/drop/create/drop-panel.js +33 -0
- package/dist/components/drop/create/drop-panel.js.map +1 -0
- package/dist/components/drop/create/launch-dialog.cjs +40 -45
- package/dist/components/drop/create/launch-dialog.cjs.map +1 -1
- package/dist/components/drop/create/launch-dialog.d.cts +4 -5
- package/dist/components/drop/create/launch-dialog.d.ts +4 -5
- package/dist/components/drop/create/launch-dialog.js +44 -49
- package/dist/components/drop/create/launch-dialog.js.map +1 -1
- package/dist/components/drop/create/settings-panel.cjs +97 -0
- package/dist/components/drop/create/settings-panel.cjs.map +1 -0
- package/dist/components/drop/create/settings-panel.d.cts +11 -0
- package/dist/components/drop/create/settings-panel.d.ts +11 -0
- package/dist/components/drop/create/settings-panel.js +73 -0
- package/dist/components/drop/create/settings-panel.js.map +1 -0
- package/dist/components/drop/drop-features.cjs +3 -3
- package/dist/components/drop/drop-features.cjs.map +1 -1
- package/dist/components/drop/drop-features.js +3 -3
- package/dist/components/drop/drop-features.js.map +1 -1
- package/dist/components/drop/drop-status.d.cts +1 -0
- package/dist/components/drop/drop-status.d.ts +1 -0
- package/dist/components/drop/page/drop-action-box.cjs +4 -4
- package/dist/components/drop/page/drop-action-box.cjs.map +1 -1
- package/dist/components/drop/page/drop-action-box.d.cts +1 -0
- package/dist/components/drop/page/drop-action-box.d.ts +1 -0
- package/dist/components/drop/page/drop-action-box.js +4 -4
- package/dist/components/drop/page/drop-action-box.js.map +1 -1
- package/dist/components/drop/page/drop-mint-dialog.cjs +1 -1
- package/dist/components/drop/page/drop-mint-dialog.cjs.map +1 -1
- package/dist/components/drop/page/drop-mint-dialog.d.cts +2 -1
- package/dist/components/drop/page/drop-mint-dialog.d.ts +2 -1
- package/dist/components/drop/page/drop-mint-dialog.js +1 -1
- package/dist/components/drop/page/drop-mint-dialog.js.map +1 -1
- package/dist/components/drop/page/drop-page.cjs +4 -8
- package/dist/components/drop/page/drop-page.cjs.map +1 -1
- package/dist/components/drop/page/drop-page.js +5 -9
- package/dist/components/drop/page/drop-page.js.map +1 -1
- package/dist/components/fast-mint/fast-mint.d.cts +2 -2
- package/dist/components/fast-mint/fast-mint.d.ts +2 -2
- package/dist/components/launchpad/edition-mint-schema.d.cts +4 -4
- package/dist/components/launchpad/edition-mint-schema.d.ts +4 -4
- package/dist/draft-B0fPlVZS.d.ts +86 -0
- package/dist/draft-Bw3JWkOZ.d.cts +86 -0
- package/dist/i18n/catalog/pt.cjs +78 -28
- package/dist/i18n/catalog/pt.cjs.map +1 -1
- package/dist/i18n/catalog/pt.js +78 -28
- package/dist/i18n/catalog/pt.js.map +1 -1
- package/dist/i18n/index.cjs.map +1 -1
- package/dist/i18n/index.d.cts +1 -1
- package/dist/i18n/index.d.ts +1 -1
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/translate.cjs.map +1 -1
- package/dist/i18n/translate.d.cts +5 -1
- package/dist/i18n/translate.d.ts +5 -1
- package/dist/i18n/translate.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js.map +1 -1
- package/dist/utils/drop/draft-store.cjs +133 -0
- package/dist/utils/drop/draft-store.cjs.map +1 -0
- package/dist/utils/drop/draft-store.d.cts +23 -0
- package/dist/utils/drop/draft-store.d.ts +23 -0
- package/dist/utils/drop/draft-store.js +107 -0
- package/dist/utils/drop/draft-store.js.map +1 -0
- package/dist/utils/drop/draft.cjs +62 -38
- package/dist/utils/drop/draft.cjs.map +1 -1
- package/dist/utils/drop/draft.d.cts +2 -38
- package/dist/utils/drop/draft.d.ts +2 -38
- package/dist/utils/drop/draft.js +58 -37
- package/dist/utils/drop/draft.js.map +1 -1
- package/dist/utils/drop/metadata.cjs +35 -16
- package/dist/utils/drop/metadata.cjs.map +1 -1
- package/dist/utils/drop/metadata.d.cts +4 -28
- package/dist/utils/drop/metadata.d.ts +4 -28
- package/dist/utils/drop/metadata.js +33 -15
- package/dist/utils/drop/metadata.js.map +1 -1
- package/dist/utils/drop/sale.cjs +10 -9
- package/dist/utils/drop/sale.cjs.map +1 -1
- package/dist/utils/drop/sale.d.cts +3 -2
- package/dist/utils/drop/sale.d.ts +3 -2
- package/dist/utils/drop/sale.js +10 -9
- package/dist/utils/drop/sale.js.map +1 -1
- package/dist/utils/drop/view.cjs +15 -13
- package/dist/utils/drop/view.cjs.map +1 -1
- package/dist/utils/drop/view.d.cts +6 -4
- package/dist/utils/drop/view.d.ts +6 -4
- package/dist/utils/drop/view.js +15 -13
- package/dist/utils/drop/view.js.map +1 -1
- package/dist/utils/media-wallet/use-erc20-balance.d.cts +1 -1
- package/dist/utils/media-wallet/use-erc20-balance.d.ts +1 -1
- package/package.json +1 -1
|
@@ -19,25 +19,29 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var draft_exports = {};
|
|
20
20
|
__export(draft_exports, {
|
|
21
21
|
EMPTY_DRAFT: () => EMPTY_DRAFT,
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
draftTokens: () => draftTokens,
|
|
23
|
+
dropSymbol: () => dropSymbol,
|
|
24
|
+
firstMissing: () => firstMissing,
|
|
25
|
+
hasErrors: () => hasErrors,
|
|
26
|
+
newAsset: () => newAsset,
|
|
24
27
|
validateDropDraft: () => validateDropDraft
|
|
25
28
|
});
|
|
26
29
|
module.exports = __toCommonJS(draft_exports);
|
|
30
|
+
var import_sdk = require("@medialane/sdk");
|
|
27
31
|
var import_launchpad_rules = require("../launchpad-rules.js");
|
|
32
|
+
var import_launchpad_defaults = require("../launchpad-defaults.js");
|
|
28
33
|
var import_allowlist = require("./allowlist.js");
|
|
29
34
|
var import_metadata = require("./metadata.js");
|
|
30
35
|
var import_sale = require("./sale.js");
|
|
31
36
|
var import_format = require("../../i18n/format.js");
|
|
37
|
+
var import_translate = require("../../i18n/translate.js");
|
|
32
38
|
const EMPTY_DRAFT = {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
symbol: "",
|
|
40
|
-
description: "",
|
|
39
|
+
collection: { name: "", description: "", externalUrl: "", cover: null },
|
|
40
|
+
assets: [],
|
|
41
|
+
mixOrder: true,
|
|
42
|
+
sale: import_sale.EMPTY_SALE,
|
|
43
|
+
listOnly: false,
|
|
44
|
+
allowlist: "",
|
|
41
45
|
license: {
|
|
42
46
|
ipType: "Art",
|
|
43
47
|
licenseType: "CC BY-SA",
|
|
@@ -48,47 +52,67 @@ const EMPTY_DRAFT = {
|
|
|
48
52
|
aiPolicy: "Allowed",
|
|
49
53
|
royalty: "0"
|
|
50
54
|
},
|
|
51
|
-
sale: import_sale.EMPTY_SALE,
|
|
52
|
-
listOnly: false,
|
|
53
|
-
allowlist: "",
|
|
54
55
|
gated: { enabled: false, title: "", url: "", type: "" }
|
|
55
56
|
};
|
|
56
|
-
function
|
|
57
|
-
return
|
|
57
|
+
function newAsset(file) {
|
|
58
|
+
return { id: crypto.randomUUID(), file, name: "", description: "", copies: "1", traits: [] };
|
|
59
|
+
}
|
|
60
|
+
function dropSymbol(name) {
|
|
61
|
+
return (0, import_launchpad_defaults.suggestLaunchpadSymbol)(name) || "DROP";
|
|
62
|
+
}
|
|
63
|
+
function draftTokens(d) {
|
|
64
|
+
return d.assets.reduce((n, a) => n + ((0, import_launchpad_rules.isPositiveInteger)(a.copies) ? Number(a.copies) : 0), 0);
|
|
65
|
+
}
|
|
66
|
+
const HTTPS = /^https:\/\//;
|
|
67
|
+
const RESERVED = new Map([...import_sdk.RESERVED_TRAITS].map((t) => [t.toLowerCase(), t]));
|
|
68
|
+
function assetErrors(a) {
|
|
69
|
+
const e = {};
|
|
70
|
+
if (!(0, import_launchpad_rules.isPositiveInteger)(a.copies)) e.copies = { text: (0, import_translate.msg)("Enter 1 or more") };
|
|
71
|
+
const reserved = a.traits.map((t) => RESERVED.get(t.key.trim().toLowerCase())).find(Boolean);
|
|
72
|
+
if (reserved) e.traits = { text: (0, import_translate.msg)("{name} is set by the license terms"), vars: { name: reserved } };
|
|
73
|
+
return Object.keys(e).length > 0 ? e : null;
|
|
58
74
|
}
|
|
59
|
-
const thousands = (0, import_format.formatNumber)(import_metadata.MAX_DROP_SUPPLY);
|
|
60
75
|
function validateDropDraft(d, now) {
|
|
61
|
-
const
|
|
62
|
-
if (d.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
e
|
|
67
|
-
|
|
68
|
-
e.artwork = `A collection holds up to ${thousands} items`;
|
|
76
|
+
const collection = {};
|
|
77
|
+
if (!d.collection.name.trim()) collection.name = { text: (0, import_translate.msg)("Name the collection") };
|
|
78
|
+
if (d.collection.externalUrl.trim() && !HTTPS.test(d.collection.externalUrl.trim())) collection.externalUrl = { text: (0, import_translate.msg)("Add a link starting with https://") };
|
|
79
|
+
const assets = { byId: {} };
|
|
80
|
+
for (const a of d.assets) {
|
|
81
|
+
const e = assetErrors(a);
|
|
82
|
+
if (e) assets.byId[a.id] = e;
|
|
69
83
|
}
|
|
70
|
-
if (
|
|
71
|
-
if (
|
|
84
|
+
if (d.assets.length === 0) assets.list = { text: (0, import_translate.msg)("Add an asset") };
|
|
85
|
+
else if (draftTokens(d) > import_metadata.MAX_DROP_SUPPLY) assets.list = { text: (0, import_translate.msg)("Up to {count} tokens"), vars: { count: (0, import_format.formatNumber)(import_metadata.MAX_DROP_SUPPLY) } };
|
|
86
|
+
const settings = { ...(0, import_sale.validateSale)(d.sale, now) };
|
|
72
87
|
if (d.listOnly) {
|
|
73
88
|
const list = (0, import_allowlist.parseAllowlist)(d.allowlist);
|
|
74
|
-
if (list.invalid.length > 0) {
|
|
75
|
-
|
|
76
|
-
e.allowlist = `${n} line${n === 1 ? " isn't a wallet address" : "s aren't wallet addresses"}: ${list.invalid.slice(0, 3).join(", ")}`;
|
|
77
|
-
} else if (list.addresses.length === 0) {
|
|
78
|
-
e.allowlist = "Add at least one wallet address";
|
|
79
|
-
}
|
|
89
|
+
if (list.invalid.length > 0) settings.allowlist = { text: (0, import_translate.msg)("Not wallet addresses: {lines}"), vars: { lines: list.invalid.slice(0, 3).join(", ") } };
|
|
90
|
+
else if (list.addresses.length === 0) settings.allowlist = { text: (0, import_translate.msg)("Add at least one wallet address") };
|
|
80
91
|
}
|
|
81
|
-
if (d.gated.enabled &&
|
|
82
|
-
return
|
|
92
|
+
if (d.gated.enabled && !HTTPS.test(d.gated.url)) settings.gated = { text: (0, import_translate.msg)("Add a link starting with https://") };
|
|
93
|
+
return { collection, assets, settings };
|
|
94
|
+
}
|
|
95
|
+
const firstValue = (o) => Object.values(o).find((v) => !!v && typeof v === "object" && "text" in v);
|
|
96
|
+
function firstMissing(e) {
|
|
97
|
+
const collection = firstValue(e.collection);
|
|
98
|
+
if (collection) return { panel: "collection", message: collection };
|
|
99
|
+
const asset = e.assets.list ?? Object.values(e.assets.byId).map(firstValue).find(Boolean);
|
|
100
|
+
if (asset) return { panel: "assets", message: asset };
|
|
101
|
+
const settings = firstValue(e.settings);
|
|
102
|
+
if (settings) return { panel: "settings", message: settings };
|
|
103
|
+
return null;
|
|
83
104
|
}
|
|
84
|
-
function
|
|
85
|
-
return
|
|
105
|
+
function hasErrors(e) {
|
|
106
|
+
return firstMissing(e) !== null;
|
|
86
107
|
}
|
|
87
108
|
// Annotate the CommonJS export names for ESM import in node:
|
|
88
109
|
0 && (module.exports = {
|
|
89
110
|
EMPTY_DRAFT,
|
|
90
|
-
|
|
91
|
-
|
|
111
|
+
draftTokens,
|
|
112
|
+
dropSymbol,
|
|
113
|
+
firstMissing,
|
|
114
|
+
hasErrors,
|
|
115
|
+
newAsset,
|
|
92
116
|
validateDropDraft
|
|
93
117
|
});
|
|
94
118
|
//# sourceMappingURL=draft.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/drop/draft.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/drop/draft.ts"],"sourcesContent":["import { RESERVED_TRAITS } from \"@medialane/sdk\";\nimport { isPositiveInteger } from \"../launchpad-rules.js\";\nimport { suggestLaunchpadSymbol } from \"../launchpad-defaults.js\";\nimport { parseAllowlist } from \"./allowlist.js\";\nimport { MAX_DROP_SUPPLY, type DropLicense } from \"./metadata.js\";\nimport { EMPTY_SALE, validateSale, type SaleDraft, type SaleErrors } from \"./sale.js\";\nimport { formatNumber } from \"../../i18n/format.js\";\nimport { msg, type Phrase } from \"../../i18n/translate.js\";\n\nexport interface DraftTrait {\n key: string;\n value: string;\n}\n\nexport interface DraftAsset {\n id: string;\n file: File;\n name: string;\n description: string;\n copies: string;\n traits: DraftTrait[];\n}\n\nexport interface DropDraft {\n collection: { name: string; description: string; externalUrl: string; cover: File | null };\n assets: DraftAsset[];\n mixOrder: boolean;\n sale: SaleDraft;\n listOnly: boolean;\n allowlist: string;\n license: DropLicense;\n gated: { enabled: boolean; title: string; url: string; type: string };\n}\n\nexport const EMPTY_DRAFT: DropDraft = {\n collection: { name: \"\", description: \"\", externalUrl: \"\", cover: null },\n assets: [],\n mixOrder: true,\n sale: EMPTY_SALE,\n listOnly: false,\n allowlist: \"\",\n license: {\n ipType: \"Art\", licenseType: \"CC BY-SA\", commercialUse: \"Yes\", derivatives: \"Share-Alike\",\n attribution: \"Required\", geographicScope: \"Worldwide\", aiPolicy: \"Allowed\", royalty: \"0\",\n },\n gated: { enabled: false, title: \"\", url: \"\", type: \"\" },\n};\n\nexport function newAsset(file: File): DraftAsset {\n return { id: crypto.randomUUID(), file, name: \"\", description: \"\", copies: \"1\", traits: [] };\n}\n\nexport function dropSymbol(name: string): string {\n return suggestLaunchpadSymbol(name) || \"DROP\";\n}\n\nexport function draftTokens(d: DropDraft): number {\n return d.assets.reduce((n, a) => n + (isPositiveInteger(a.copies) ? Number(a.copies) : 0), 0);\n}\n\nexport type DropPanel = \"collection\" | \"assets\" | \"settings\";\n\ntype AssetErrors = Partial<Record<\"copies\" | \"traits\", Phrase>>;\n\nexport interface DropDraftErrors {\n collection: Partial<Record<\"name\" | \"externalUrl\", Phrase>>;\n assets: { list?: Phrase; byId: Record<string, AssetErrors> };\n settings: SaleErrors & Partial<Record<\"allowlist\" | \"gated\", Phrase>>;\n}\n\nconst HTTPS = /^https:\\/\\//;\nconst RESERVED = new Map([...RESERVED_TRAITS].map((t) => [t.toLowerCase(), t]));\n\nfunction assetErrors(a: DraftAsset): AssetErrors | null {\n const e: AssetErrors = {};\n if (!isPositiveInteger(a.copies)) e.copies = { text: msg(\"Enter 1 or more\") };\n const reserved = a.traits.map((t) => RESERVED.get(t.key.trim().toLowerCase())).find(Boolean);\n if (reserved) e.traits = { text: msg(\"{name} is set by the license terms\"), vars: { name: reserved } };\n return Object.keys(e).length > 0 ? e : null;\n}\n\nexport function validateDropDraft(d: DropDraft, now: number): DropDraftErrors {\n const collection: DropDraftErrors[\"collection\"] = {};\n if (!d.collection.name.trim()) collection.name = { text: msg(\"Name the collection\") };\n if (d.collection.externalUrl.trim() && !HTTPS.test(d.collection.externalUrl.trim())) collection.externalUrl = { text: msg(\"Add a link starting with https://\") };\n\n const assets: DropDraftErrors[\"assets\"] = { byId: {} };\n for (const a of d.assets) {\n const e = assetErrors(a);\n if (e) assets.byId[a.id] = e;\n }\n if (d.assets.length === 0) assets.list = { text: msg(\"Add an asset\") };\n else if (draftTokens(d) > MAX_DROP_SUPPLY) assets.list = { text: msg(\"Up to {count} tokens\"), vars: { count: formatNumber(MAX_DROP_SUPPLY) } };\n\n const settings: DropDraftErrors[\"settings\"] = { ...validateSale(d.sale, now) };\n if (d.listOnly) {\n const list = parseAllowlist(d.allowlist);\n if (list.invalid.length > 0) settings.allowlist = { text: msg(\"Not wallet addresses: {lines}\"), vars: { lines: list.invalid.slice(0, 3).join(\", \") } };\n else if (list.addresses.length === 0) settings.allowlist = { text: msg(\"Add at least one wallet address\") };\n }\n if (d.gated.enabled && !HTTPS.test(d.gated.url)) settings.gated = { text: msg(\"Add a link starting with https://\") };\n return { collection, assets, settings };\n}\n\nconst firstValue = (o: object): Phrase | undefined => Object.values(o).find((v): v is Phrase => !!v && typeof v === \"object\" && \"text\" in v);\n\nexport function firstMissing(e: DropDraftErrors): { panel: DropPanel; message: Phrase } | null {\n const collection = firstValue(e.collection);\n if (collection) return { panel: \"collection\", message: collection };\n const asset = e.assets.list ?? Object.values(e.assets.byId).map(firstValue).find(Boolean);\n if (asset) return { panel: \"assets\", message: asset };\n const settings = firstValue(e.settings);\n if (settings) return { panel: \"settings\", message: settings };\n return null;\n}\n\nexport function hasErrors(e: DropDraftErrors): boolean {\n return firstMissing(e) !== null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAgC;AAChC,6BAAkC;AAClC,gCAAuC;AACvC,uBAA+B;AAC/B,sBAAkD;AAClD,kBAA0E;AAC1E,oBAA6B;AAC7B,uBAAiC;AA2B1B,MAAM,cAAyB;AAAA,EACpC,YAAY,EAAE,MAAM,IAAI,aAAa,IAAI,aAAa,IAAI,OAAO,KAAK;AAAA,EACtE,QAAQ,CAAC;AAAA,EACT,UAAU;AAAA,EACV,MAAM;AAAA,EACN,UAAU;AAAA,EACV,WAAW;AAAA,EACX,SAAS;AAAA,IACP,QAAQ;AAAA,IAAO,aAAa;AAAA,IAAY,eAAe;AAAA,IAAO,aAAa;AAAA,IAC3E,aAAa;AAAA,IAAY,iBAAiB;AAAA,IAAa,UAAU;AAAA,IAAW,SAAS;AAAA,EACvF;AAAA,EACA,OAAO,EAAE,SAAS,OAAO,OAAO,IAAI,KAAK,IAAI,MAAM,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AE,KAAK,OAAO;AACxF,MAAI,MAAO,QAAO,EAAE,OAAO,UAAU,SAAS,MAAM;AACpD,QAAM,WAAW,WAAW,EAAE,QAAQ;AACtC,MAAI,SAAU,QAAO,EAAE,OAAO,YAAY,SAAS,SAAS;AAC5D,SAAO;AACT;AAEO,SAAS,UAAU,GAA6B;AACrD,SAAO,aAAa,CAAC,MAAM;AAC7B;","names":[]}
|
|
@@ -1,40 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { SaleDraft, SaleErrors } from './sale.cjs';
|
|
1
|
+
export { D as DraftAsset, j as DraftTrait, a as DropDraft, b as DropDraftErrors, k as DropPanel, E as EMPTY_DRAFT, l as draftTokens, d as dropSymbol, n as firstMissing, o as hasErrors, p as newAsset, v as validateDropDraft } from '../../draft-Bw3JWkOZ.cjs';
|
|
2
|
+
import './sale.cjs';
|
|
4
3
|
import '../../i18n/translate.cjs';
|
|
5
4
|
import '@medialane/sdk';
|
|
6
|
-
|
|
7
|
-
interface DraftItem {
|
|
8
|
-
id: string;
|
|
9
|
-
file: File;
|
|
10
|
-
previewUrl: string;
|
|
11
|
-
name: string;
|
|
12
|
-
description: string;
|
|
13
|
-
}
|
|
14
|
-
interface DropDraft {
|
|
15
|
-
kind: DropKind;
|
|
16
|
-
edition: File | null;
|
|
17
|
-
supply: string;
|
|
18
|
-
items: DraftItem[];
|
|
19
|
-
cover: File | null;
|
|
20
|
-
name: string;
|
|
21
|
-
symbol: string;
|
|
22
|
-
description: string;
|
|
23
|
-
license: DropLicense;
|
|
24
|
-
sale: SaleDraft;
|
|
25
|
-
listOnly: boolean;
|
|
26
|
-
allowlist: string;
|
|
27
|
-
gated: {
|
|
28
|
-
enabled: boolean;
|
|
29
|
-
title: string;
|
|
30
|
-
url: string;
|
|
31
|
-
type: string;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
declare const EMPTY_DRAFT: DropDraft;
|
|
35
|
-
type DropDraftErrors = SaleErrors & Partial<Record<"artwork" | "supply" | "name" | "symbol" | "allowlist" | "gated", string>>;
|
|
36
|
-
declare function draftSupply(d: DropDraft): number;
|
|
37
|
-
declare function validateDropDraft(d: DropDraft, now: number): DropDraftErrors;
|
|
38
|
-
declare function supplyLabel(t: T, kind: DropKind, supply: number, formatted: string): string;
|
|
39
|
-
|
|
40
|
-
export { type DraftItem, type DropDraft, type DropDraftErrors, EMPTY_DRAFT, draftSupply, supplyLabel, validateDropDraft };
|
|
@@ -1,40 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { SaleDraft, SaleErrors } from './sale.js';
|
|
1
|
+
export { D as DraftAsset, j as DraftTrait, a as DropDraft, b as DropDraftErrors, k as DropPanel, E as EMPTY_DRAFT, l as draftTokens, d as dropSymbol, n as firstMissing, o as hasErrors, p as newAsset, v as validateDropDraft } from '../../draft-B0fPlVZS.js';
|
|
2
|
+
import './sale.js';
|
|
4
3
|
import '../../i18n/translate.js';
|
|
5
4
|
import '@medialane/sdk';
|
|
6
|
-
|
|
7
|
-
interface DraftItem {
|
|
8
|
-
id: string;
|
|
9
|
-
file: File;
|
|
10
|
-
previewUrl: string;
|
|
11
|
-
name: string;
|
|
12
|
-
description: string;
|
|
13
|
-
}
|
|
14
|
-
interface DropDraft {
|
|
15
|
-
kind: DropKind;
|
|
16
|
-
edition: File | null;
|
|
17
|
-
supply: string;
|
|
18
|
-
items: DraftItem[];
|
|
19
|
-
cover: File | null;
|
|
20
|
-
name: string;
|
|
21
|
-
symbol: string;
|
|
22
|
-
description: string;
|
|
23
|
-
license: DropLicense;
|
|
24
|
-
sale: SaleDraft;
|
|
25
|
-
listOnly: boolean;
|
|
26
|
-
allowlist: string;
|
|
27
|
-
gated: {
|
|
28
|
-
enabled: boolean;
|
|
29
|
-
title: string;
|
|
30
|
-
url: string;
|
|
31
|
-
type: string;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
declare const EMPTY_DRAFT: DropDraft;
|
|
35
|
-
type DropDraftErrors = SaleErrors & Partial<Record<"artwork" | "supply" | "name" | "symbol" | "allowlist" | "gated", string>>;
|
|
36
|
-
declare function draftSupply(d: DropDraft): number;
|
|
37
|
-
declare function validateDropDraft(d: DropDraft, now: number): DropDraftErrors;
|
|
38
|
-
declare function supplyLabel(t: T, kind: DropKind, supply: number, formatted: string): string;
|
|
39
|
-
|
|
40
|
-
export { type DraftItem, type DropDraft, type DropDraftErrors, EMPTY_DRAFT, draftSupply, supplyLabel, validateDropDraft };
|
package/dist/utils/drop/draft.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RESERVED_TRAITS } from "@medialane/sdk";
|
|
2
|
+
import { isPositiveInteger } from "../launchpad-rules.js";
|
|
3
|
+
import { suggestLaunchpadSymbol } from "../launchpad-defaults.js";
|
|
2
4
|
import { parseAllowlist } from "./allowlist.js";
|
|
3
5
|
import { MAX_DROP_SUPPLY } from "./metadata.js";
|
|
4
6
|
import { EMPTY_SALE, validateSale } from "./sale.js";
|
|
5
7
|
import { formatNumber } from "../../i18n/format.js";
|
|
8
|
+
import { msg } from "../../i18n/translate.js";
|
|
6
9
|
const EMPTY_DRAFT = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
symbol: "",
|
|
14
|
-
description: "",
|
|
10
|
+
collection: { name: "", description: "", externalUrl: "", cover: null },
|
|
11
|
+
assets: [],
|
|
12
|
+
mixOrder: true,
|
|
13
|
+
sale: EMPTY_SALE,
|
|
14
|
+
listOnly: false,
|
|
15
|
+
allowlist: "",
|
|
15
16
|
license: {
|
|
16
17
|
ipType: "Art",
|
|
17
18
|
licenseType: "CC BY-SA",
|
|
@@ -22,46 +23,66 @@ const EMPTY_DRAFT = {
|
|
|
22
23
|
aiPolicy: "Allowed",
|
|
23
24
|
royalty: "0"
|
|
24
25
|
},
|
|
25
|
-
sale: EMPTY_SALE,
|
|
26
|
-
listOnly: false,
|
|
27
|
-
allowlist: "",
|
|
28
26
|
gated: { enabled: false, title: "", url: "", type: "" }
|
|
29
27
|
};
|
|
30
|
-
function
|
|
31
|
-
return
|
|
28
|
+
function newAsset(file) {
|
|
29
|
+
return { id: crypto.randomUUID(), file, name: "", description: "", copies: "1", traits: [] };
|
|
30
|
+
}
|
|
31
|
+
function dropSymbol(name) {
|
|
32
|
+
return suggestLaunchpadSymbol(name) || "DROP";
|
|
33
|
+
}
|
|
34
|
+
function draftTokens(d) {
|
|
35
|
+
return d.assets.reduce((n, a) => n + (isPositiveInteger(a.copies) ? Number(a.copies) : 0), 0);
|
|
36
|
+
}
|
|
37
|
+
const HTTPS = /^https:\/\//;
|
|
38
|
+
const RESERVED = new Map([...RESERVED_TRAITS].map((t) => [t.toLowerCase(), t]));
|
|
39
|
+
function assetErrors(a) {
|
|
40
|
+
const e = {};
|
|
41
|
+
if (!isPositiveInteger(a.copies)) e.copies = { text: msg("Enter 1 or more") };
|
|
42
|
+
const reserved = a.traits.map((t) => RESERVED.get(t.key.trim().toLowerCase())).find(Boolean);
|
|
43
|
+
if (reserved) e.traits = { text: msg("{name} is set by the license terms"), vars: { name: reserved } };
|
|
44
|
+
return Object.keys(e).length > 0 ? e : null;
|
|
32
45
|
}
|
|
33
|
-
const thousands = formatNumber(MAX_DROP_SUPPLY);
|
|
34
46
|
function validateDropDraft(d, now) {
|
|
35
|
-
const
|
|
36
|
-
if (d.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
e
|
|
41
|
-
|
|
42
|
-
e.artwork = `A collection holds up to ${thousands} items`;
|
|
47
|
+
const collection = {};
|
|
48
|
+
if (!d.collection.name.trim()) collection.name = { text: msg("Name the collection") };
|
|
49
|
+
if (d.collection.externalUrl.trim() && !HTTPS.test(d.collection.externalUrl.trim())) collection.externalUrl = { text: msg("Add a link starting with https://") };
|
|
50
|
+
const assets = { byId: {} };
|
|
51
|
+
for (const a of d.assets) {
|
|
52
|
+
const e = assetErrors(a);
|
|
53
|
+
if (e) assets.byId[a.id] = e;
|
|
43
54
|
}
|
|
44
|
-
if (
|
|
45
|
-
if (
|
|
55
|
+
if (d.assets.length === 0) assets.list = { text: msg("Add an asset") };
|
|
56
|
+
else if (draftTokens(d) > MAX_DROP_SUPPLY) assets.list = { text: msg("Up to {count} tokens"), vars: { count: formatNumber(MAX_DROP_SUPPLY) } };
|
|
57
|
+
const settings = { ...validateSale(d.sale, now) };
|
|
46
58
|
if (d.listOnly) {
|
|
47
59
|
const list = parseAllowlist(d.allowlist);
|
|
48
|
-
if (list.invalid.length > 0) {
|
|
49
|
-
|
|
50
|
-
e.allowlist = `${n} line${n === 1 ? " isn't a wallet address" : "s aren't wallet addresses"}: ${list.invalid.slice(0, 3).join(", ")}`;
|
|
51
|
-
} else if (list.addresses.length === 0) {
|
|
52
|
-
e.allowlist = "Add at least one wallet address";
|
|
53
|
-
}
|
|
60
|
+
if (list.invalid.length > 0) settings.allowlist = { text: msg("Not wallet addresses: {lines}"), vars: { lines: list.invalid.slice(0, 3).join(", ") } };
|
|
61
|
+
else if (list.addresses.length === 0) settings.allowlist = { text: msg("Add at least one wallet address") };
|
|
54
62
|
}
|
|
55
|
-
if (d.gated.enabled &&
|
|
56
|
-
return
|
|
63
|
+
if (d.gated.enabled && !HTTPS.test(d.gated.url)) settings.gated = { text: msg("Add a link starting with https://") };
|
|
64
|
+
return { collection, assets, settings };
|
|
65
|
+
}
|
|
66
|
+
const firstValue = (o) => Object.values(o).find((v) => !!v && typeof v === "object" && "text" in v);
|
|
67
|
+
function firstMissing(e) {
|
|
68
|
+
const collection = firstValue(e.collection);
|
|
69
|
+
if (collection) return { panel: "collection", message: collection };
|
|
70
|
+
const asset = e.assets.list ?? Object.values(e.assets.byId).map(firstValue).find(Boolean);
|
|
71
|
+
if (asset) return { panel: "assets", message: asset };
|
|
72
|
+
const settings = firstValue(e.settings);
|
|
73
|
+
if (settings) return { panel: "settings", message: settings };
|
|
74
|
+
return null;
|
|
57
75
|
}
|
|
58
|
-
function
|
|
59
|
-
return
|
|
76
|
+
function hasErrors(e) {
|
|
77
|
+
return firstMissing(e) !== null;
|
|
60
78
|
}
|
|
61
79
|
export {
|
|
62
80
|
EMPTY_DRAFT,
|
|
63
|
-
|
|
64
|
-
|
|
81
|
+
draftTokens,
|
|
82
|
+
dropSymbol,
|
|
83
|
+
firstMissing,
|
|
84
|
+
hasErrors,
|
|
85
|
+
newAsset,
|
|
65
86
|
validateDropDraft
|
|
66
87
|
};
|
|
67
88
|
//# sourceMappingURL=draft.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/drop/draft.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/drop/draft.ts"],"sourcesContent":["import { RESERVED_TRAITS } from \"@medialane/sdk\";\nimport { isPositiveInteger } from \"../launchpad-rules.js\";\nimport { suggestLaunchpadSymbol } from \"../launchpad-defaults.js\";\nimport { parseAllowlist } from \"./allowlist.js\";\nimport { MAX_DROP_SUPPLY, type DropLicense } from \"./metadata.js\";\nimport { EMPTY_SALE, validateSale, type SaleDraft, type SaleErrors } from \"./sale.js\";\nimport { formatNumber } from \"../../i18n/format.js\";\nimport { msg, type Phrase } from \"../../i18n/translate.js\";\n\nexport interface DraftTrait {\n key: string;\n value: string;\n}\n\nexport interface DraftAsset {\n id: string;\n file: File;\n name: string;\n description: string;\n copies: string;\n traits: DraftTrait[];\n}\n\nexport interface DropDraft {\n collection: { name: string; description: string; externalUrl: string; cover: File | null };\n assets: DraftAsset[];\n mixOrder: boolean;\n sale: SaleDraft;\n listOnly: boolean;\n allowlist: string;\n license: DropLicense;\n gated: { enabled: boolean; title: string; url: string; type: string };\n}\n\nexport const EMPTY_DRAFT: DropDraft = {\n collection: { name: \"\", description: \"\", externalUrl: \"\", cover: null },\n assets: [],\n mixOrder: true,\n sale: EMPTY_SALE,\n listOnly: false,\n allowlist: \"\",\n license: {\n ipType: \"Art\", licenseType: \"CC BY-SA\", commercialUse: \"Yes\", derivatives: \"Share-Alike\",\n attribution: \"Required\", geographicScope: \"Worldwide\", aiPolicy: \"Allowed\", royalty: \"0\",\n },\n gated: { enabled: false, title: \"\", url: \"\", type: \"\" },\n};\n\nexport function newAsset(file: File): DraftAsset {\n return { id: crypto.randomUUID(), file, name: \"\", description: \"\", copies: \"1\", traits: [] };\n}\n\nexport function dropSymbol(name: string): string {\n return suggestLaunchpadSymbol(name) || \"DROP\";\n}\n\nexport function draftTokens(d: DropDraft): number {\n return d.assets.reduce((n, a) => n + (isPositiveInteger(a.copies) ? Number(a.copies) : 0), 0);\n}\n\nexport type DropPanel = \"collection\" | \"assets\" | \"settings\";\n\ntype AssetErrors = Partial<Record<\"copies\" | \"traits\", Phrase>>;\n\nexport interface DropDraftErrors {\n collection: Partial<Record<\"name\" | \"externalUrl\", Phrase>>;\n assets: { list?: Phrase; byId: Record<string, AssetErrors> };\n settings: SaleErrors & Partial<Record<\"allowlist\" | \"gated\", Phrase>>;\n}\n\nconst HTTPS = /^https:\\/\\//;\nconst RESERVED = new Map([...RESERVED_TRAITS].map((t) => [t.toLowerCase(), t]));\n\nfunction assetErrors(a: DraftAsset): AssetErrors | null {\n const e: AssetErrors = {};\n if (!isPositiveInteger(a.copies)) e.copies = { text: msg(\"Enter 1 or more\") };\n const reserved = a.traits.map((t) => RESERVED.get(t.key.trim().toLowerCase())).find(Boolean);\n if (reserved) e.traits = { text: msg(\"{name} is set by the license terms\"), vars: { name: reserved } };\n return Object.keys(e).length > 0 ? e : null;\n}\n\nexport function validateDropDraft(d: DropDraft, now: number): DropDraftErrors {\n const collection: DropDraftErrors[\"collection\"] = {};\n if (!d.collection.name.trim()) collection.name = { text: msg(\"Name the collection\") };\n if (d.collection.externalUrl.trim() && !HTTPS.test(d.collection.externalUrl.trim())) collection.externalUrl = { text: msg(\"Add a link starting with https://\") };\n\n const assets: DropDraftErrors[\"assets\"] = { byId: {} };\n for (const a of d.assets) {\n const e = assetErrors(a);\n if (e) assets.byId[a.id] = e;\n }\n if (d.assets.length === 0) assets.list = { text: msg(\"Add an asset\") };\n else if (draftTokens(d) > MAX_DROP_SUPPLY) assets.list = { text: msg(\"Up to {count} tokens\"), vars: { count: formatNumber(MAX_DROP_SUPPLY) } };\n\n const settings: DropDraftErrors[\"settings\"] = { ...validateSale(d.sale, now) };\n if (d.listOnly) {\n const list = parseAllowlist(d.allowlist);\n if (list.invalid.length > 0) settings.allowlist = { text: msg(\"Not wallet addresses: {lines}\"), vars: { lines: list.invalid.slice(0, 3).join(\", \") } };\n else if (list.addresses.length === 0) settings.allowlist = { text: msg(\"Add at least one wallet address\") };\n }\n if (d.gated.enabled && !HTTPS.test(d.gated.url)) settings.gated = { text: msg(\"Add a link starting with https://\") };\n return { collection, assets, settings };\n}\n\nconst firstValue = (o: object): Phrase | undefined => Object.values(o).find((v): v is Phrase => !!v && typeof v === \"object\" && \"text\" in v);\n\nexport function firstMissing(e: DropDraftErrors): { panel: DropPanel; message: Phrase } | null {\n const collection = firstValue(e.collection);\n if (collection) return { panel: \"collection\", message: collection };\n const asset = e.assets.list ?? Object.values(e.assets.byId).map(firstValue).find(Boolean);\n if (asset) return { panel: \"assets\", message: asset };\n const settings = firstValue(e.settings);\n if (settings) return { panel: \"settings\", message: settings };\n return null;\n}\n\nexport function hasErrors(e: DropDraftErrors): boolean {\n return firstMissing(e) !== null;\n}\n"],"mappings":"AAAA,SAAS,uBAAuB;AAChC,SAAS,yBAAyB;AAClC,SAAS,8BAA8B;AACvC,SAAS,sBAAsB;AAC/B,SAAS,uBAAyC;AAClD,SAAS,YAAY,oBAAqD;AAC1E,SAAS,oBAAoB;AAC7B,SAAS,WAAwB;AA2B1B,MAAM,cAAyB;AAAA,EACpC,YAAY,EAAE,MAAM,IAAI,aAAa,IAAI,aAAa,IAAI,OAAO,KAAK;AAAA,EACtE,QAAQ,CAAC;AAAA,EACT,UAAU;AAAA,EACV,MAAM;AAAA,EACN,UAAU;AAAA,EACV,WAAW;AAAA,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AAU,CAAC;AAEpI,SAAS,aAAa,GAAkE;AAC7F,QAAM,aAAa,WAAW,EAAE,UAAU;AAC1C,MAAI,WAAY,QAAO,EAAE,OAAO,cAAc,SAAS,WAAW;AAClE,QAAM,QAAQ,EAAE,OAAO,QAAQ,OAAO,OAAO,EAAE,OAAO,IAAI,EAAE,IAAI,UAAU,EAAE,KAAK,OAAO;AACxF,MAAI,MAAO,QAAO,EAAE,OAAO,UAAU,SAAS,MAAM;AACpD,QAAM,WAAW,WAAW,EAAE,QAAQ;AACtC,MAAI,SAAU,QAAO,EAAE,OAAO,YAAY,SAAS,SAAS;AAC5D,SAAO;AACT;AAEO,SAAS,UAAU,GAA6B;AACrD,SAAO,aAAa,CAAC,MAAM;AAC7B;","names":[]}
|
|
@@ -21,37 +21,55 @@ __export(metadata_exports, {
|
|
|
21
21
|
MAX_DROP_METADATA_BYTES: () => MAX_DROP_METADATA_BYTES,
|
|
22
22
|
MAX_DROP_SUPPLY: () => MAX_DROP_SUPPLY,
|
|
23
23
|
buildDropMetadataFiles: () => buildDropMetadataFiles,
|
|
24
|
-
metadataBytes: () => metadataBytes
|
|
24
|
+
metadataBytes: () => metadataBytes,
|
|
25
|
+
tokenOrder: () => tokenOrder
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(metadata_exports);
|
|
27
28
|
var import_sdk = require("@medialane/sdk");
|
|
28
29
|
const MAX_DROP_SUPPLY = 2e3;
|
|
29
30
|
const MAX_DROP_METADATA_BYTES = 5 * 1024 * 1024;
|
|
31
|
+
function secureRandom(n) {
|
|
32
|
+
const [value] = crypto.getRandomValues(new Uint32Array(1));
|
|
33
|
+
return value % n;
|
|
34
|
+
}
|
|
35
|
+
function tokenOrder(copies, mix, random = secureRandom) {
|
|
36
|
+
const order = copies.flatMap((count, asset) => Array.from({ length: count }, () => asset));
|
|
37
|
+
if (!mix) return order;
|
|
38
|
+
for (let i = order.length - 1; i > 0; i--) {
|
|
39
|
+
const j = random(i + 1);
|
|
40
|
+
[order[i], order[j]] = [order[j], order[i]];
|
|
41
|
+
}
|
|
42
|
+
return order;
|
|
43
|
+
}
|
|
30
44
|
function buildDropMetadataFiles(input) {
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const files =
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
45
|
+
const externalUrl = input.externalUrl.trim() || null;
|
|
46
|
+
const seen = input.assets.map(() => 0);
|
|
47
|
+
const files = input.order.map((index, i) => {
|
|
48
|
+
const id = i + 1;
|
|
49
|
+
const asset = input.assets[index];
|
|
50
|
+
seen[index] += 1;
|
|
51
|
+
return {
|
|
37
52
|
name: String(id),
|
|
38
53
|
content: (0, import_sdk.buildAssetMetadata)({
|
|
39
54
|
...input.license,
|
|
40
|
-
name:
|
|
41
|
-
description:
|
|
42
|
-
|
|
55
|
+
name: asset.name.trim() || `${input.name} #${id}`,
|
|
56
|
+
description: asset.description.trim() || input.description,
|
|
57
|
+
externalUrl,
|
|
58
|
+
imageUri: asset.imageUri,
|
|
43
59
|
creator: input.creator,
|
|
44
|
-
edition:
|
|
60
|
+
edition: asset.copies > 1 ? `${seen[index]}/${asset.copies}` : null,
|
|
61
|
+
templateTraits: asset.traits.map((t) => ({ traitType: t.key, value: t.value }))
|
|
45
62
|
})
|
|
46
|
-
}
|
|
47
|
-
}
|
|
63
|
+
};
|
|
64
|
+
});
|
|
48
65
|
files.push({
|
|
49
66
|
name: "collection.json",
|
|
50
67
|
content: {
|
|
51
68
|
name: input.name,
|
|
52
69
|
description: input.description,
|
|
53
|
-
image: input.coverUri ?? input.
|
|
54
|
-
|
|
70
|
+
image: input.coverUri ?? input.assets[0]?.imageUri ?? null,
|
|
71
|
+
...externalUrl ? { external_link: externalUrl } : {},
|
|
72
|
+
drop_kind: input.assets.length > 1 ? "collection" : "edition"
|
|
55
73
|
}
|
|
56
74
|
});
|
|
57
75
|
return files;
|
|
@@ -64,6 +82,7 @@ function metadataBytes(files) {
|
|
|
64
82
|
MAX_DROP_METADATA_BYTES,
|
|
65
83
|
MAX_DROP_SUPPLY,
|
|
66
84
|
buildDropMetadataFiles,
|
|
67
|
-
metadataBytes
|
|
85
|
+
metadataBytes,
|
|
86
|
+
tokenOrder
|
|
68
87
|
});
|
|
69
88
|
//# sourceMappingURL=metadata.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/utils/drop/metadata.ts"],"sourcesContent":["import { buildAssetMetadata, type BuildAssetMetadataInput } from \"@medialane/sdk\";\n\nexport const MAX_DROP_SUPPLY = 2000;\nexport const MAX_DROP_METADATA_BYTES = 5 * 1024 * 1024;\n\nexport type DropKind = \"edition\" | \"collection\";\n\nexport type DropLicense = Record<\n keyof Pick<BuildAssetMetadataInput, \"ipType\" | \"licenseType\" | \"commercialUse\" | \"derivatives\" | \"attribution\" | \"geographicScope\" | \"aiPolicy\" | \"royalty\">,\n string\n>;\n\nexport interface DropMetadataInput {\n
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/drop/metadata.ts"],"sourcesContent":["import { buildAssetMetadata, type BuildAssetMetadataInput } from \"@medialane/sdk\";\nimport type { DraftTrait } from \"./draft.js\";\n\nexport const MAX_DROP_SUPPLY = 2000;\nexport const MAX_DROP_METADATA_BYTES = 5 * 1024 * 1024;\n\nexport type DropKind = \"edition\" | \"collection\";\n\nexport type DropLicense = Record<\n keyof Pick<BuildAssetMetadataInput, \"ipType\" | \"licenseType\" | \"commercialUse\" | \"derivatives\" | \"attribution\" | \"geographicScope\" | \"aiPolicy\" | \"royalty\">,\n string\n>;\n\nexport interface DropMetadataInput {\n name: string;\n description: string;\n externalUrl: string;\n creator: string;\n coverUri: string | null;\n license: DropLicense;\n assets: { name: string; description: string; imageUri: string; copies: number; traits: DraftTrait[] }[];\n order: number[];\n}\n\nexport interface DropMetadataFile {\n name: string;\n content: unknown;\n}\n\nfunction secureRandom(n: number): number {\n const [value] = crypto.getRandomValues(new Uint32Array(1));\n return value! % n;\n}\n\nexport function tokenOrder(copies: number[], mix: boolean, random: (n: number) => number = secureRandom): number[] {\n const order = copies.flatMap((count, asset) => Array.from({ length: count }, () => asset));\n if (!mix) return order;\n for (let i = order.length - 1; i > 0; i--) {\n const j = random(i + 1);\n [order[i], order[j]] = [order[j]!, order[i]!];\n }\n return order;\n}\n\nexport function buildDropMetadataFiles(input: DropMetadataInput): DropMetadataFile[] {\n const externalUrl = input.externalUrl.trim() || null;\n const seen = input.assets.map(() => 0);\n const files: DropMetadataFile[] = input.order.map((index, i) => {\n const id = i + 1;\n const asset = input.assets[index]!;\n seen[index]! += 1;\n return {\n name: String(id),\n content: buildAssetMetadata({\n ...input.license,\n name: asset.name.trim() || `${input.name} #${id}`,\n description: asset.description.trim() || input.description,\n externalUrl,\n imageUri: asset.imageUri,\n creator: input.creator,\n edition: asset.copies > 1 ? `${seen[index]}/${asset.copies}` : null,\n templateTraits: asset.traits.map((t) => ({ traitType: t.key, value: t.value })),\n }),\n };\n });\n files.push({\n name: \"collection.json\",\n content: {\n name: input.name,\n description: input.description,\n image: input.coverUri ?? input.assets[0]?.imageUri ?? null,\n ...(externalUrl ? { external_link: externalUrl } : {}),\n drop_kind: (input.assets.length > 1 ? \"collection\" : \"edition\") satisfies DropKind,\n },\n });\n return files;\n}\n\nexport function metadataBytes(files: DropMetadataFile[]): number {\n return files.reduce((n, f) => n + JSON.stringify(f.content).length, 0);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAiE;AAG1D,MAAM,kBAAkB;AACxB,MAAM,0BAA0B,IAAI,OAAO;AAyBlD,SAAS,aAAa,GAAmB;AACvC,QAAM,CAAC,KAAK,IAAI,OAAO,gBAAgB,IAAI,YAAY,CAAC,CAAC;AACzD,SAAO,QAAS;AAClB;AAEO,SAAS,WAAW,QAAkB,KAAc,SAAgC,cAAwB;AACjH,QAAM,QAAQ,OAAO,QAAQ,CAAC,OAAO,UAAU,MAAM,KA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,EAAE,eAAe,YAAY,IAAI,CAAC;AAAA,MACpD,WAAY,MAAM,OAAO,SAAS,IAAI,eAAe;AAAA,IACvD;AAAA,EACF,CAAC;AACD,SAAO;AACT;AAEO,SAAS,cAAc,OAAmC;AAC/D,SAAO,MAAM,OAAO,CAAC,GAAG,MAAM,IAAI,KAAK,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC;AACvE;","names":[]}
|
|
@@ -1,28 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type DropKind = "edition" | "collection";
|
|
6
|
-
type DropLicense = Record<keyof Pick<BuildAssetMetadataInput, "ipType" | "licenseType" | "commercialUse" | "derivatives" | "attribution" | "geographicScope" | "aiPolicy" | "royalty">, string>;
|
|
7
|
-
interface DropMetadataInput {
|
|
8
|
-
kind: DropKind;
|
|
9
|
-
name: string;
|
|
10
|
-
description: string;
|
|
11
|
-
creator: string;
|
|
12
|
-
coverUri: string | null;
|
|
13
|
-
license: DropLicense;
|
|
14
|
-
items: {
|
|
15
|
-
name: string;
|
|
16
|
-
description: string;
|
|
17
|
-
imageUri: string;
|
|
18
|
-
}[];
|
|
19
|
-
supply: number;
|
|
20
|
-
}
|
|
21
|
-
interface DropMetadataFile {
|
|
22
|
-
name: string;
|
|
23
|
-
content: unknown;
|
|
24
|
-
}
|
|
25
|
-
declare function buildDropMetadataFiles(input: DropMetadataInput): DropMetadataFile[];
|
|
26
|
-
declare function metadataBytes(files: DropMetadataFile[]): number;
|
|
27
|
-
|
|
28
|
-
export { type DropKind, type DropLicense, type DropMetadataFile, type DropMetadataInput, MAX_DROP_METADATA_BYTES, MAX_DROP_SUPPLY, buildDropMetadataFiles, metadataBytes };
|
|
1
|
+
import '@medialane/sdk';
|
|
2
|
+
export { c as DropKind, e as DropLicense, f as DropMetadataFile, g as DropMetadataInput, M as MAX_DROP_METADATA_BYTES, h as MAX_DROP_SUPPLY, i as buildDropMetadataFiles, m as metadataBytes, t as tokenOrder } from '../../draft-Bw3JWkOZ.cjs';
|
|
3
|
+
import './sale.cjs';
|
|
4
|
+
import '../../i18n/translate.cjs';
|
|
@@ -1,28 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type DropKind = "edition" | "collection";
|
|
6
|
-
type DropLicense = Record<keyof Pick<BuildAssetMetadataInput, "ipType" | "licenseType" | "commercialUse" | "derivatives" | "attribution" | "geographicScope" | "aiPolicy" | "royalty">, string>;
|
|
7
|
-
interface DropMetadataInput {
|
|
8
|
-
kind: DropKind;
|
|
9
|
-
name: string;
|
|
10
|
-
description: string;
|
|
11
|
-
creator: string;
|
|
12
|
-
coverUri: string | null;
|
|
13
|
-
license: DropLicense;
|
|
14
|
-
items: {
|
|
15
|
-
name: string;
|
|
16
|
-
description: string;
|
|
17
|
-
imageUri: string;
|
|
18
|
-
}[];
|
|
19
|
-
supply: number;
|
|
20
|
-
}
|
|
21
|
-
interface DropMetadataFile {
|
|
22
|
-
name: string;
|
|
23
|
-
content: unknown;
|
|
24
|
-
}
|
|
25
|
-
declare function buildDropMetadataFiles(input: DropMetadataInput): DropMetadataFile[];
|
|
26
|
-
declare function metadataBytes(files: DropMetadataFile[]): number;
|
|
27
|
-
|
|
28
|
-
export { type DropKind, type DropLicense, type DropMetadataFile, type DropMetadataInput, MAX_DROP_METADATA_BYTES, MAX_DROP_SUPPLY, buildDropMetadataFiles, metadataBytes };
|
|
1
|
+
import '@medialane/sdk';
|
|
2
|
+
export { c as DropKind, e as DropLicense, f as DropMetadataFile, g as DropMetadataInput, M as MAX_DROP_METADATA_BYTES, h as MAX_DROP_SUPPLY, i as buildDropMetadataFiles, m as metadataBytes, t as tokenOrder } from '../../draft-B0fPlVZS.js';
|
|
3
|
+
import './sale.js';
|
|
4
|
+
import '../../i18n/translate.js';
|