@medialane/ui 0.236.0 → 0.237.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.
@@ -0,0 +1,244 @@
1
+ "use strict";
2
+ "use client";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var edition_mint_exports = {};
31
+ __export(edition_mint_exports, {
32
+ EditionMint: () => EditionMint
33
+ });
34
+ module.exports = __toCommonJS(edition_mint_exports);
35
+ var import_jsx_runtime = require("react/jsx-runtime");
36
+ var import_react = require("react");
37
+ var import_react_hook_form = require("react-hook-form");
38
+ var import_zod = require("@hookform/resolvers/zod");
39
+ var import_lucide_react = require("lucide-react");
40
+ var import_sdk = require("@medialane/sdk");
41
+ var import_starknet = require("@medialane/sdk/starknet");
42
+ var import_link = __toESM(require("../link.js"), 1);
43
+ var import_button = require("../button.js");
44
+ var import_form = require("../form.js");
45
+ var import_claim_route_shell = require("../claim-route-shell.js");
46
+ var import_creation_success = require("../creation-success.js");
47
+ var import_medialane_collection_card = require("../medialane-collection-card.js");
48
+ var import_transaction_dialog = require("../transaction-dialog.js");
49
+ var import_wallet_required = require("../wallet-required.js");
50
+ var import_medialane_app = require("../medialane-app.js");
51
+ var import_reward_earned = require("../rewards/reward-earned.js");
52
+ var import_edition_mint_fields = require("./edition-mint-fields.js");
53
+ var import_edition_mint_schema = require("./edition-mint-schema.js");
54
+ var import_run_intent_calls = require("../../utils/run-intent-calls.js");
55
+ var import_ipfs_upload = require("../../utils/ipfs-upload.js");
56
+ var import_use_transaction = require("../../utils/use-transaction.js");
57
+ var import_use_launchpad_image_upload = require("../../utils/use-launchpad-image-upload.js");
58
+ var import_portfolio_cache = require("../../utils/portfolio-cache.js");
59
+ const DEFAULTS = {
60
+ value: "1",
61
+ recipient: "",
62
+ name: "",
63
+ description: "",
64
+ external_url: "",
65
+ ipType: "NFT",
66
+ licenseType: "CC BY-SA",
67
+ commercialUse: "Yes",
68
+ derivatives: "Share-Alike",
69
+ attribution: "Required",
70
+ geographicScope: "Worldwide",
71
+ aiPolicy: "Not Allowed",
72
+ royalty: 0
73
+ };
74
+ function EditionMint({ contract: rawContract, aside }) {
75
+ const app = (0, import_medialane_app.useMedialaneApp)();
76
+ const walletAddress = app.walletAddress;
77
+ const collectionAddress = (0, import_sdk.normalizeAddress)("STARKNET", rawContract);
78
+ const tx = (0, import_use_transaction.useTransaction)();
79
+ const upload = (0, import_use_launchpad_image_upload.useLaunchpadImageUpload)({ successMessage: "Image uploaded to IPFS", failureMessage: "Image upload failed" });
80
+ const { imagePreview, imageUri, imageUploading, uploadError, uploadSuccess, fileInputRef, handleImageSelect, clearImage } = upload;
81
+ const [ownerCheck, setOwnerCheck] = (0, import_react.useState)("loading");
82
+ const [formError, setFormError] = (0, import_react.useState)(null);
83
+ const [metadataResetKey, setMetadataResetKey] = (0, import_react.useState)(0);
84
+ const [autoExternalUrl, setAutoExternalUrl] = (0, import_react.useState)("");
85
+ const metadataFieldsRef = (0, import_react.useRef)([]);
86
+ const form = (0, import_react_hook_form.useForm)({ resolver: (0, import_zod.zodResolver)(import_edition_mint_schema.editionMintSchema), defaultValues: DEFAULTS });
87
+ (0, import_react.useEffect)(() => {
88
+ if (walletAddress && !form.getValues("recipient")) form.setValue("recipient", walletAddress);
89
+ }, [walletAddress, form]);
90
+ (0, import_react.useEffect)(() => {
91
+ const suggested = `https://medialane.io/collections/${collectionAddress}`;
92
+ const current = form.getValues("external_url");
93
+ if (!current || current === autoExternalUrl) {
94
+ form.setValue("external_url", suggested, { shouldDirty: false });
95
+ setAutoExternalUrl(suggested);
96
+ }
97
+ }, [autoExternalUrl, collectionAddress, form]);
98
+ (0, import_react.useEffect)(() => {
99
+ if (!walletAddress) return;
100
+ app.getClient().api.collections.get(collectionAddress).then((data) => {
101
+ const owner = data.owner ? (0, import_sdk.normalizeAddress)("STARKNET", data.owner) : null;
102
+ setOwnerCheck(owner === (0, import_sdk.normalizeAddress)("STARKNET", walletAddress) ? "ok" : "denied");
103
+ }).catch(() => setOwnerCheck("denied"));
104
+ }, [app, walletAddress, collectionAddress]);
105
+ const uploadDocument = async (file) => {
106
+ await app.ensureSignedIn?.();
107
+ return (await (0, import_ipfs_upload.uploadFileToIpfs)(app.getClient().api, file, "document")).uri;
108
+ };
109
+ const handleAgain = () => {
110
+ tx.reset();
111
+ metadataFieldsRef.current = [];
112
+ setMetadataResetKey((key) => key + 1);
113
+ setAutoExternalUrl("");
114
+ clearImage();
115
+ form.reset({ ...DEFAULTS, recipient: walletAddress ?? "" });
116
+ };
117
+ const onSubmit = (values) => {
118
+ if (!imageUri) {
119
+ setFormError("Upload an image before minting.");
120
+ return;
121
+ }
122
+ if (!walletAddress) return;
123
+ setFormError(null);
124
+ void tx.run(async (signer) => {
125
+ await app.ensureSignedIn?.();
126
+ const api = app.getClient().api;
127
+ const pinned = await (0, import_ipfs_upload.pinAssetMetadata)(api, {
128
+ name: values.name,
129
+ description: values.description ?? "",
130
+ imageUri,
131
+ externalUrl: values.external_url,
132
+ ipType: values.ipType,
133
+ licenseType: values.licenseType,
134
+ commercialUse: values.commercialUse,
135
+ derivatives: values.derivatives,
136
+ attribution: values.attribution,
137
+ geographicScope: values.geographicScope,
138
+ aiPolicy: values.aiPolicy,
139
+ royalty: String(values.royalty),
140
+ creator: walletAddress,
141
+ templateTraits: metadataFieldsRef.current.filter((f) => f.traitType.trim() && f.value.trim()).map((f) => ({ traitType: f.traitType.trim(), value: f.value.trim() }))
142
+ });
143
+ await (0, import_run_intent_calls.runIntentCalls)(
144
+ signer,
145
+ () => api.intents.create("mint", {
146
+ owner: walletAddress,
147
+ recipient: values.recipient,
148
+ collectionContract: collectionAddress,
149
+ tokenUri: pinned.uri,
150
+ value: values.value,
151
+ royaltyBps: 0
152
+ })
153
+ );
154
+ (0, import_portfolio_cache.invalidatePortfolioCache)(walletAddress);
155
+ });
156
+ };
157
+ const mintedTokenId = tx.receipt ? (0, import_starknet.mintedTokenIdFromReceipt)(tx.receipt, collectionAddress) : null;
158
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
159
+ import_wallet_required.WalletRequired,
160
+ {
161
+ icon: import_lucide_react.Sparkles,
162
+ iconClassName: "text-brand-purple",
163
+ title: "Secure your account to create",
164
+ description: "Secure your account to mint tokens into a multi-editions collection.",
165
+ children: ownerCheck === "denied" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "max-w-lg mx-auto px-4 pt-24 pb-8 text-center space-y-4", children: [
166
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Sparkles, { className: "h-10 w-10 text-muted-foreground mx-auto" }),
167
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { className: "text-2xl font-bold", children: "Not the owner" }),
168
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-muted-foreground", children: "Only the collection owner can mint tokens. Connect the wallet that deployed this collection." }),
169
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { asChild: true, variant: "outline", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_link.default, { href: "/launchpad", children: "Back to Launchpad" }) })
170
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
171
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
172
+ import_claim_route_shell.ClaimRouteShell,
173
+ {
174
+ icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Sparkles, { className: "h-4 w-4 text-white" }),
175
+ title: "Mint an Edition",
176
+ subtitle: "Add a new piece to your collection \u2014 its details and authorship are saved permanently. Free to mint, and it's yours.",
177
+ headerAccessory: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex items-center gap-2 rounded-lg border border-border bg-background/60 px-3 py-2 max-w-full", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "tabular-nums text-xs text-foreground/80 truncate", children: [
178
+ "Collection: ",
179
+ collectionAddress
180
+ ] }) }),
181
+ aside: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
182
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
183
+ import_medialane_collection_card.MedialaneCollectionCard,
184
+ {
185
+ image: imagePreview,
186
+ name: form.watch("name"),
187
+ collection: "Edition",
188
+ serial: Number(form.watch("value")) > 1 ? `${form.watch("value")} editions` : void 0,
189
+ creator: walletAddress ? `${walletAddress.slice(0, 6)}\u2026${walletAddress.slice(-4)}` : void 0,
190
+ creatorHref: walletAddress ? (0, import_sdk.profileHref)({ address: walletAddress }) : void 0
191
+ }
192
+ ),
193
+ aside
194
+ ] }),
195
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_form.Form, { ...form, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { onSubmit: form.handleSubmit(onSubmit), className: "space-y-5", children: [
196
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
197
+ import_edition_mint_fields.EditionMintFields,
198
+ {
199
+ form,
200
+ imagePreview,
201
+ imageUri,
202
+ imageUploading,
203
+ mintDisabled: imageUploading || tx.phase !== "idle",
204
+ fileInputRef,
205
+ onImageSelect: handleImageSelect,
206
+ onClearImage: clearImage,
207
+ metadataResetKey,
208
+ onMetadataFieldsChange: (fields) => {
209
+ metadataFieldsRef.current = fields;
210
+ },
211
+ uploadDocument
212
+ }
213
+ ),
214
+ uploadError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-xs text-destructive mt-1", children: uploadError }),
215
+ uploadSuccess && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "text-xs text-emerald-500 mt-1", children: [
216
+ "\u2713 ",
217
+ uploadSuccess
218
+ ] }),
219
+ formError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-xs text-destructive mt-1", children: formError })
220
+ ] }) })
221
+ }
222
+ ),
223
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_transaction_dialog.TransactionDialog, { tx, title: "Mint an edition", workingLabel: "Minting your edition\u2026", firstStepLabel: "Upload metadata", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
224
+ import_creation_success.CreationSuccess,
225
+ {
226
+ name: form.getValues("name") || "Your token",
227
+ image: imagePreview,
228
+ caption: "Your edition is live",
229
+ primary: mintedTokenId ? { href: (0, import_sdk.assetHref)("STARKNET", collectionAddress, mintedTokenId), label: "View asset" } : { href: "/portfolio/assets", label: "View portfolio" },
230
+ secondary: mintedTokenId ? { href: "/portfolio/assets", label: "View portfolio" } : void 0,
231
+ onAgain: handleAgain,
232
+ againLabel: "Mint another",
233
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_reward_earned.RewardEarned, { actionType: "mint_asset" })
234
+ }
235
+ ) })
236
+ ] })
237
+ }
238
+ );
239
+ }
240
+ // Annotate the CommonJS export names for ESM import in node:
241
+ 0 && (module.exports = {
242
+ EditionMint
243
+ });
244
+ //# sourceMappingURL=edition-mint.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/launchpad/edition-mint.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, useState, type ReactNode } from \"react\";\nimport { useForm } from \"react-hook-form\";\nimport { zodResolver } from \"@hookform/resolvers/zod\";\nimport { Sparkles } from \"lucide-react\";\nimport { assetHref, normalizeAddress, profileHref } from \"@medialane/sdk\";\nimport { mintedTokenIdFromReceipt } from \"@medialane/sdk/starknet\";\nimport Link from \"../link.js\";\nimport { Button } from \"../button.js\";\nimport { Form } from \"../form.js\";\nimport { ClaimRouteShell } from \"../claim-route-shell.js\";\nimport { CreationSuccess } from \"../creation-success.js\";\nimport { MedialaneCollectionCard } from \"../medialane-collection-card.js\";\nimport { TransactionDialog } from \"../transaction-dialog.js\";\nimport { WalletRequired } from \"../wallet-required.js\";\nimport { useMedialaneApp } from \"../medialane-app.js\";\nimport { RewardEarned } from \"../rewards/reward-earned.js\";\nimport type { MetadataField } from \"../ip-type-fields.js\";\nimport { EditionMintFields } from \"./edition-mint-fields.js\";\nimport { editionMintSchema, type EditionMintValues } from \"./edition-mint-schema.js\";\nimport { runIntentCalls } from \"../../utils/run-intent-calls.js\";\nimport { pinAssetMetadata, uploadFileToIpfs } from \"../../utils/ipfs-upload.js\";\nimport { useTransaction } from \"../../utils/use-transaction.js\";\nimport { useLaunchpadImageUpload } from \"../../utils/use-launchpad-image-upload.js\";\nimport { invalidatePortfolioCache } from \"../../utils/portfolio-cache.js\";\n\nconst DEFAULTS: EditionMintValues = {\n value: \"1\",\n recipient: \"\",\n name: \"\",\n description: \"\",\n external_url: \"\",\n ipType: \"NFT\",\n licenseType: \"CC BY-SA\",\n commercialUse: \"Yes\",\n derivatives: \"Share-Alike\",\n attribution: \"Required\",\n geographicScope: \"Worldwide\",\n aiPolicy: \"Not Allowed\",\n royalty: 0,\n};\n\nexport function EditionMint({ contract: rawContract, aside }: { contract: string; aside?: ReactNode }) {\n const app = useMedialaneApp();\n const walletAddress = app.walletAddress;\n const collectionAddress = normalizeAddress(\"STARKNET\", rawContract);\n const tx = useTransaction();\n const upload = useLaunchpadImageUpload({ successMessage: \"Image uploaded to IPFS\", failureMessage: \"Image upload failed\" });\n const { imagePreview, imageUri, imageUploading, uploadError, uploadSuccess, fileInputRef, handleImageSelect, clearImage } = upload;\n const [ownerCheck, setOwnerCheck] = useState<\"loading\" | \"ok\" | \"denied\">(\"loading\");\n const [formError, setFormError] = useState<string | null>(null);\n const [metadataResetKey, setMetadataResetKey] = useState(0);\n const [autoExternalUrl, setAutoExternalUrl] = useState(\"\");\n const metadataFieldsRef = useRef<MetadataField[]>([]);\n\n const form = useForm<EditionMintValues>({ resolver: zodResolver(editionMintSchema), defaultValues: DEFAULTS });\n\n useEffect(() => {\n if (walletAddress && !form.getValues(\"recipient\")) form.setValue(\"recipient\", walletAddress);\n }, [walletAddress, form]);\n\n useEffect(() => {\n const suggested = `https://medialane.io/collections/${collectionAddress}`;\n const current = form.getValues(\"external_url\");\n if (!current || current === autoExternalUrl) {\n form.setValue(\"external_url\", suggested, { shouldDirty: false });\n setAutoExternalUrl(suggested);\n }\n }, [autoExternalUrl, collectionAddress, form]);\n\n useEffect(() => {\n if (!walletAddress) return;\n app\n .getClient()\n .api.collections.get(collectionAddress)\n .then((data) => {\n const owner = data.owner ? normalizeAddress(\"STARKNET\", data.owner) : null;\n setOwnerCheck(owner === normalizeAddress(\"STARKNET\", walletAddress) ? \"ok\" : \"denied\");\n })\n .catch(() => setOwnerCheck(\"denied\"));\n }, [app, walletAddress, collectionAddress]);\n\n const uploadDocument = async (file: File) => {\n await app.ensureSignedIn?.();\n return (await uploadFileToIpfs(app.getClient().api, file, \"document\")).uri;\n };\n\n const handleAgain = () => {\n tx.reset();\n metadataFieldsRef.current = [];\n setMetadataResetKey((key) => key + 1);\n setAutoExternalUrl(\"\");\n clearImage();\n form.reset({ ...DEFAULTS, recipient: walletAddress ?? \"\" });\n };\n\n const onSubmit = (values: EditionMintValues) => {\n if (!imageUri) {\n setFormError(\"Upload an image before minting.\");\n return;\n }\n if (!walletAddress) return;\n setFormError(null);\n void tx.run(async (signer) => {\n await app.ensureSignedIn?.();\n const api = app.getClient().api;\n const pinned = await pinAssetMetadata(api, {\n name: values.name,\n description: values.description ?? \"\",\n imageUri,\n externalUrl: values.external_url,\n ipType: values.ipType,\n licenseType: values.licenseType,\n commercialUse: values.commercialUse,\n derivatives: values.derivatives,\n attribution: values.attribution,\n geographicScope: values.geographicScope,\n aiPolicy: values.aiPolicy,\n royalty: String(values.royalty),\n creator: walletAddress,\n templateTraits: metadataFieldsRef.current.filter((f) => f.traitType.trim() && f.value.trim()).map((f) => ({ traitType: f.traitType.trim(), value: f.value.trim() })),\n });\n await runIntentCalls(signer, () =>\n api.intents.create(\"mint\", {\n owner: walletAddress,\n recipient: values.recipient,\n collectionContract: collectionAddress,\n tokenUri: pinned.uri,\n value: values.value,\n royaltyBps: 0,\n }),\n );\n invalidatePortfolioCache(walletAddress);\n });\n };\n\n const mintedTokenId = tx.receipt ? mintedTokenIdFromReceipt(tx.receipt, collectionAddress) : null;\n\n return (\n <WalletRequired\n icon={Sparkles}\n iconClassName=\"text-brand-purple\"\n title=\"Secure your account to create\"\n description=\"Secure your account to mint tokens into a multi-editions collection.\"\n >\n {ownerCheck === \"denied\" ? (\n <div className=\"max-w-lg mx-auto px-4 pt-24 pb-8 text-center space-y-4\">\n <Sparkles className=\"h-10 w-10 text-muted-foreground mx-auto\" />\n <h1 className=\"text-2xl font-bold\">Not the owner</h1>\n <p className=\"text-muted-foreground\">Only the collection owner can mint tokens. Connect the wallet that deployed this collection.</p>\n <Button asChild variant=\"outline\">\n <Link href=\"/launchpad\">Back to Launchpad</Link>\n </Button>\n </div>\n ) : (\n <>\n <ClaimRouteShell\n icon={<Sparkles className=\"h-4 w-4 text-white\" />}\n title=\"Mint an Edition\"\n subtitle=\"Add a new piece to your collection — its details and authorship are saved permanently. Free to mint, and it's yours.\"\n headerAccessory={\n <div className=\"flex items-center gap-2 rounded-lg border border-border bg-background/60 px-3 py-2 max-w-full\">\n <span className=\"tabular-nums text-xs text-foreground/80 truncate\">Collection: {collectionAddress}</span>\n </div>\n }\n aside={\n <>\n <MedialaneCollectionCard\n image={imagePreview}\n name={form.watch(\"name\")}\n collection=\"Edition\"\n serial={Number(form.watch(\"value\")) > 1 ? `${form.watch(\"value\")} editions` : undefined}\n creator={walletAddress ? `${walletAddress.slice(0, 6)}…${walletAddress.slice(-4)}` : undefined}\n creatorHref={walletAddress ? profileHref({ address: walletAddress }) : undefined}\n />\n {aside}\n </>\n }\n >\n <Form {...form}>\n <form onSubmit={form.handleSubmit(onSubmit)} className=\"space-y-5\">\n <EditionMintFields\n form={form}\n imagePreview={imagePreview}\n imageUri={imageUri}\n imageUploading={imageUploading}\n mintDisabled={imageUploading || tx.phase !== \"idle\"}\n fileInputRef={fileInputRef}\n onImageSelect={handleImageSelect}\n onClearImage={clearImage}\n metadataResetKey={metadataResetKey}\n onMetadataFieldsChange={(fields) => { metadataFieldsRef.current = fields; }}\n uploadDocument={uploadDocument}\n />\n {uploadError && <p className=\"text-xs text-destructive mt-1\">{uploadError}</p>}\n {uploadSuccess && <p className=\"text-xs text-emerald-500 mt-1\">✓ {uploadSuccess}</p>}\n {formError && <p className=\"text-xs text-destructive mt-1\">{formError}</p>}\n </form>\n </Form>\n </ClaimRouteShell>\n\n <TransactionDialog tx={tx} title=\"Mint an edition\" workingLabel=\"Minting your edition…\" firstStepLabel=\"Upload metadata\">\n <CreationSuccess\n name={form.getValues(\"name\") || \"Your token\"}\n image={imagePreview}\n caption=\"Your edition is live\"\n primary={mintedTokenId ? { href: assetHref(\"STARKNET\", collectionAddress, mintedTokenId), label: \"View asset\" } : { href: \"/portfolio/assets\", label: \"View portfolio\" }}\n secondary={mintedTokenId ? { href: \"/portfolio/assets\", label: \"View portfolio\" } : undefined}\n onAgain={handleAgain}\n againLabel=\"Mint another\"\n >\n <RewardEarned actionType=\"mint_asset\" />\n </CreationSuccess>\n </TransactionDialog>\n </>\n )}\n </WalletRequired>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAmJQ;AAjJR,mBAA4D;AAC5D,6BAAwB;AACxB,iBAA4B;AAC5B,0BAAyB;AACzB,iBAAyD;AACzD,sBAAyC;AACzC,kBAAiB;AACjB,oBAAuB;AACvB,kBAAqB;AACrB,+BAAgC;AAChC,8BAAgC;AAChC,uCAAwC;AACxC,gCAAkC;AAClC,6BAA+B;AAC/B,2BAAgC;AAChC,2BAA6B;AAE7B,iCAAkC;AAClC,iCAA0D;AAC1D,8BAA+B;AAC/B,yBAAmD;AACnD,6BAA+B;AAC/B,wCAAwC;AACxC,6BAAyC;AAEzC,MAAM,WAA8B;AAAA,EAClC,OAAO;AAAA,EACP,WAAW;AAAA,EACX,MAAM;AAAA,EACN,aAAa;AAAA,EACb,cAAc;AAAA,EACd,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,eAAe;AAAA,EACf,aAAa;AAAA,EACb,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,UAAU;AAAA,EACV,SAAS;AACX;AAEO,SAAS,YAAY,EAAE,UAAU,aAAa,MAAM,GAA4C;AACrG,QAAM,UAAM,sCAAgB;AAC5B,QAAM,gBAAgB,IAAI;AAC1B,QAAM,wBAAoB,6BAAiB,YAAY,WAAW;AAClE,QAAM,SAAK,uCAAe;AAC1B,QAAM,aAAS,2DAAwB,EAAE,gBAAgB,0BAA0B,gBAAgB,sBAAsB,CAAC;AAC1H,QAAM,EAAE,cAAc,UAAU,gBAAgB,aAAa,eAAe,cAAc,mBAAmB,WAAW,IAAI;AAC5H,QAAM,CAAC,Y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AG,WAAU,aACrD;AAAA;AAAA,gBAAC;AAAA;AAAA,kBACC;AAAA,kBACA;AAAA,kBACA;AAAA,kBACA;AAAA,kBACA,cAAc,kBAAkB,GAAG,UAAU;AAAA,kBAC7C;AAAA,kBACA,eAAe;AAAA,kBACf,cAAc;AAAA,kBACd;AAAA,kBACA,wBAAwB,CAAC,WAAW;AAAE,sCAAkB,UAAU;AAAA,kBAAQ;AAAA,kBAC1E;AAAA;AAAA,cACF;AAAA,cACC,eAAe,4CAAC,OAAE,WAAU,iCAAiC,uBAAY;AAAA,cACzE,iBAAiB,6CAAC,OAAE,WAAU,iCAAgC;AAAA;AAAA,gBAAG;AAAA,iBAAc;AAAA,cAC/E,aAAa,4CAAC,OAAE,WAAU,iCAAiC,qBAAU;AAAA,eACxE,GACF;AAAA;AAAA,QACF;AAAA,QAEA,4CAAC,+CAAkB,IAAQ,OAAM,mBAAkB,cAAa,8BAAwB,gBAAe,mBACrG;AAAA,UAAC;AAAA;AAAA,YACC,MAAM,KAAK,UAAU,MAAM,KAAK;AAAA,YAChC,OAAO;AAAA,YACP,SAAQ;AAAA,YACR,SAAS,gBAAgB,EAAE,UAAM,sBAAU,YAAY,mBAAmB,aAAa,GAAG,OAAO,aAAa,IAAI,EAAE,MAAM,qBAAqB,OAAO,iBAAiB;AAAA,YACvK,WAAW,gBAAgB,EAAE,MAAM,qBAAqB,OAAO,iBAAiB,IAAI;AAAA,YACpF,SAAS;AAAA,YACT,YAAW;AAAA,YAEX,sDAAC,qCAAa,YAAW,cAAa;AAAA;AAAA,QACxC,GACF;AAAA,SACF;AAAA;AAAA,EAEJ;AAEJ;","names":["Link"]}
@@ -0,0 +1,9 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+
4
+ declare function EditionMint({ contract: rawContract, aside }: {
5
+ contract: string;
6
+ aside?: ReactNode;
7
+ }): react_jsx_runtime.JSX.Element;
8
+
9
+ export { EditionMint };
@@ -0,0 +1,9 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+
4
+ declare function EditionMint({ contract: rawContract, aside }: {
5
+ contract: string;
6
+ aside?: ReactNode;
7
+ }): react_jsx_runtime.JSX.Element;
8
+
9
+ export { EditionMint };
@@ -0,0 +1,210 @@
1
+ "use client";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useRef, useState } from "react";
4
+ import { useForm } from "react-hook-form";
5
+ import { zodResolver } from "@hookform/resolvers/zod";
6
+ import { Sparkles } from "lucide-react";
7
+ import { assetHref, normalizeAddress, profileHref } from "@medialane/sdk";
8
+ import { mintedTokenIdFromReceipt } from "@medialane/sdk/starknet";
9
+ import Link from "../link.js";
10
+ import { Button } from "../button.js";
11
+ import { Form } from "../form.js";
12
+ import { ClaimRouteShell } from "../claim-route-shell.js";
13
+ import { CreationSuccess } from "../creation-success.js";
14
+ import { MedialaneCollectionCard } from "../medialane-collection-card.js";
15
+ import { TransactionDialog } from "../transaction-dialog.js";
16
+ import { WalletRequired } from "../wallet-required.js";
17
+ import { useMedialaneApp } from "../medialane-app.js";
18
+ import { RewardEarned } from "../rewards/reward-earned.js";
19
+ import { EditionMintFields } from "./edition-mint-fields.js";
20
+ import { editionMintSchema } from "./edition-mint-schema.js";
21
+ import { runIntentCalls } from "../../utils/run-intent-calls.js";
22
+ import { pinAssetMetadata, uploadFileToIpfs } from "../../utils/ipfs-upload.js";
23
+ import { useTransaction } from "../../utils/use-transaction.js";
24
+ import { useLaunchpadImageUpload } from "../../utils/use-launchpad-image-upload.js";
25
+ import { invalidatePortfolioCache } from "../../utils/portfolio-cache.js";
26
+ const DEFAULTS = {
27
+ value: "1",
28
+ recipient: "",
29
+ name: "",
30
+ description: "",
31
+ external_url: "",
32
+ ipType: "NFT",
33
+ licenseType: "CC BY-SA",
34
+ commercialUse: "Yes",
35
+ derivatives: "Share-Alike",
36
+ attribution: "Required",
37
+ geographicScope: "Worldwide",
38
+ aiPolicy: "Not Allowed",
39
+ royalty: 0
40
+ };
41
+ function EditionMint({ contract: rawContract, aside }) {
42
+ const app = useMedialaneApp();
43
+ const walletAddress = app.walletAddress;
44
+ const collectionAddress = normalizeAddress("STARKNET", rawContract);
45
+ const tx = useTransaction();
46
+ const upload = useLaunchpadImageUpload({ successMessage: "Image uploaded to IPFS", failureMessage: "Image upload failed" });
47
+ const { imagePreview, imageUri, imageUploading, uploadError, uploadSuccess, fileInputRef, handleImageSelect, clearImage } = upload;
48
+ const [ownerCheck, setOwnerCheck] = useState("loading");
49
+ const [formError, setFormError] = useState(null);
50
+ const [metadataResetKey, setMetadataResetKey] = useState(0);
51
+ const [autoExternalUrl, setAutoExternalUrl] = useState("");
52
+ const metadataFieldsRef = useRef([]);
53
+ const form = useForm({ resolver: zodResolver(editionMintSchema), defaultValues: DEFAULTS });
54
+ useEffect(() => {
55
+ if (walletAddress && !form.getValues("recipient")) form.setValue("recipient", walletAddress);
56
+ }, [walletAddress, form]);
57
+ useEffect(() => {
58
+ const suggested = `https://medialane.io/collections/${collectionAddress}`;
59
+ const current = form.getValues("external_url");
60
+ if (!current || current === autoExternalUrl) {
61
+ form.setValue("external_url", suggested, { shouldDirty: false });
62
+ setAutoExternalUrl(suggested);
63
+ }
64
+ }, [autoExternalUrl, collectionAddress, form]);
65
+ useEffect(() => {
66
+ if (!walletAddress) return;
67
+ app.getClient().api.collections.get(collectionAddress).then((data) => {
68
+ const owner = data.owner ? normalizeAddress("STARKNET", data.owner) : null;
69
+ setOwnerCheck(owner === normalizeAddress("STARKNET", walletAddress) ? "ok" : "denied");
70
+ }).catch(() => setOwnerCheck("denied"));
71
+ }, [app, walletAddress, collectionAddress]);
72
+ const uploadDocument = async (file) => {
73
+ await app.ensureSignedIn?.();
74
+ return (await uploadFileToIpfs(app.getClient().api, file, "document")).uri;
75
+ };
76
+ const handleAgain = () => {
77
+ tx.reset();
78
+ metadataFieldsRef.current = [];
79
+ setMetadataResetKey((key) => key + 1);
80
+ setAutoExternalUrl("");
81
+ clearImage();
82
+ form.reset({ ...DEFAULTS, recipient: walletAddress ?? "" });
83
+ };
84
+ const onSubmit = (values) => {
85
+ if (!imageUri) {
86
+ setFormError("Upload an image before minting.");
87
+ return;
88
+ }
89
+ if (!walletAddress) return;
90
+ setFormError(null);
91
+ void tx.run(async (signer) => {
92
+ await app.ensureSignedIn?.();
93
+ const api = app.getClient().api;
94
+ const pinned = await pinAssetMetadata(api, {
95
+ name: values.name,
96
+ description: values.description ?? "",
97
+ imageUri,
98
+ externalUrl: values.external_url,
99
+ ipType: values.ipType,
100
+ licenseType: values.licenseType,
101
+ commercialUse: values.commercialUse,
102
+ derivatives: values.derivatives,
103
+ attribution: values.attribution,
104
+ geographicScope: values.geographicScope,
105
+ aiPolicy: values.aiPolicy,
106
+ royalty: String(values.royalty),
107
+ creator: walletAddress,
108
+ templateTraits: metadataFieldsRef.current.filter((f) => f.traitType.trim() && f.value.trim()).map((f) => ({ traitType: f.traitType.trim(), value: f.value.trim() }))
109
+ });
110
+ await runIntentCalls(
111
+ signer,
112
+ () => api.intents.create("mint", {
113
+ owner: walletAddress,
114
+ recipient: values.recipient,
115
+ collectionContract: collectionAddress,
116
+ tokenUri: pinned.uri,
117
+ value: values.value,
118
+ royaltyBps: 0
119
+ })
120
+ );
121
+ invalidatePortfolioCache(walletAddress);
122
+ });
123
+ };
124
+ const mintedTokenId = tx.receipt ? mintedTokenIdFromReceipt(tx.receipt, collectionAddress) : null;
125
+ return /* @__PURE__ */ jsx(
126
+ WalletRequired,
127
+ {
128
+ icon: Sparkles,
129
+ iconClassName: "text-brand-purple",
130
+ title: "Secure your account to create",
131
+ description: "Secure your account to mint tokens into a multi-editions collection.",
132
+ children: ownerCheck === "denied" ? /* @__PURE__ */ jsxs("div", { className: "max-w-lg mx-auto px-4 pt-24 pb-8 text-center space-y-4", children: [
133
+ /* @__PURE__ */ jsx(Sparkles, { className: "h-10 w-10 text-muted-foreground mx-auto" }),
134
+ /* @__PURE__ */ jsx("h1", { className: "text-2xl font-bold", children: "Not the owner" }),
135
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: "Only the collection owner can mint tokens. Connect the wallet that deployed this collection." }),
136
+ /* @__PURE__ */ jsx(Button, { asChild: true, variant: "outline", children: /* @__PURE__ */ jsx(Link, { href: "/launchpad", children: "Back to Launchpad" }) })
137
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
138
+ /* @__PURE__ */ jsx(
139
+ ClaimRouteShell,
140
+ {
141
+ icon: /* @__PURE__ */ jsx(Sparkles, { className: "h-4 w-4 text-white" }),
142
+ title: "Mint an Edition",
143
+ subtitle: "Add a new piece to your collection \u2014 its details and authorship are saved permanently. Free to mint, and it's yours.",
144
+ headerAccessory: /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 rounded-lg border border-border bg-background/60 px-3 py-2 max-w-full", children: /* @__PURE__ */ jsxs("span", { className: "tabular-nums text-xs text-foreground/80 truncate", children: [
145
+ "Collection: ",
146
+ collectionAddress
147
+ ] }) }),
148
+ aside: /* @__PURE__ */ jsxs(Fragment, { children: [
149
+ /* @__PURE__ */ jsx(
150
+ MedialaneCollectionCard,
151
+ {
152
+ image: imagePreview,
153
+ name: form.watch("name"),
154
+ collection: "Edition",
155
+ serial: Number(form.watch("value")) > 1 ? `${form.watch("value")} editions` : void 0,
156
+ creator: walletAddress ? `${walletAddress.slice(0, 6)}\u2026${walletAddress.slice(-4)}` : void 0,
157
+ creatorHref: walletAddress ? profileHref({ address: walletAddress }) : void 0
158
+ }
159
+ ),
160
+ aside
161
+ ] }),
162
+ children: /* @__PURE__ */ jsx(Form, { ...form, children: /* @__PURE__ */ jsxs("form", { onSubmit: form.handleSubmit(onSubmit), className: "space-y-5", children: [
163
+ /* @__PURE__ */ jsx(
164
+ EditionMintFields,
165
+ {
166
+ form,
167
+ imagePreview,
168
+ imageUri,
169
+ imageUploading,
170
+ mintDisabled: imageUploading || tx.phase !== "idle",
171
+ fileInputRef,
172
+ onImageSelect: handleImageSelect,
173
+ onClearImage: clearImage,
174
+ metadataResetKey,
175
+ onMetadataFieldsChange: (fields) => {
176
+ metadataFieldsRef.current = fields;
177
+ },
178
+ uploadDocument
179
+ }
180
+ ),
181
+ uploadError && /* @__PURE__ */ jsx("p", { className: "text-xs text-destructive mt-1", children: uploadError }),
182
+ uploadSuccess && /* @__PURE__ */ jsxs("p", { className: "text-xs text-emerald-500 mt-1", children: [
183
+ "\u2713 ",
184
+ uploadSuccess
185
+ ] }),
186
+ formError && /* @__PURE__ */ jsx("p", { className: "text-xs text-destructive mt-1", children: formError })
187
+ ] }) })
188
+ }
189
+ ),
190
+ /* @__PURE__ */ jsx(TransactionDialog, { tx, title: "Mint an edition", workingLabel: "Minting your edition\u2026", firstStepLabel: "Upload metadata", children: /* @__PURE__ */ jsx(
191
+ CreationSuccess,
192
+ {
193
+ name: form.getValues("name") || "Your token",
194
+ image: imagePreview,
195
+ caption: "Your edition is live",
196
+ primary: mintedTokenId ? { href: assetHref("STARKNET", collectionAddress, mintedTokenId), label: "View asset" } : { href: "/portfolio/assets", label: "View portfolio" },
197
+ secondary: mintedTokenId ? { href: "/portfolio/assets", label: "View portfolio" } : void 0,
198
+ onAgain: handleAgain,
199
+ againLabel: "Mint another",
200
+ children: /* @__PURE__ */ jsx(RewardEarned, { actionType: "mint_asset" })
201
+ }
202
+ ) })
203
+ ] })
204
+ }
205
+ );
206
+ }
207
+ export {
208
+ EditionMint
209
+ };
210
+ //# sourceMappingURL=edition-mint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/components/launchpad/edition-mint.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, useState, type ReactNode } from \"react\";\nimport { useForm } from \"react-hook-form\";\nimport { zodResolver } from \"@hookform/resolvers/zod\";\nimport { Sparkles } from \"lucide-react\";\nimport { assetHref, normalizeAddress, profileHref } from \"@medialane/sdk\";\nimport { mintedTokenIdFromReceipt } from \"@medialane/sdk/starknet\";\nimport Link from \"../link.js\";\nimport { Button } from \"../button.js\";\nimport { Form } from \"../form.js\";\nimport { ClaimRouteShell } from \"../claim-route-shell.js\";\nimport { CreationSuccess } from \"../creation-success.js\";\nimport { MedialaneCollectionCard } from \"../medialane-collection-card.js\";\nimport { TransactionDialog } from \"../transaction-dialog.js\";\nimport { WalletRequired } from \"../wallet-required.js\";\nimport { useMedialaneApp } from \"../medialane-app.js\";\nimport { RewardEarned } from \"../rewards/reward-earned.js\";\nimport type { MetadataField } from \"../ip-type-fields.js\";\nimport { EditionMintFields } from \"./edition-mint-fields.js\";\nimport { editionMintSchema, type EditionMintValues } from \"./edition-mint-schema.js\";\nimport { runIntentCalls } from \"../../utils/run-intent-calls.js\";\nimport { pinAssetMetadata, uploadFileToIpfs } from \"../../utils/ipfs-upload.js\";\nimport { useTransaction } from \"../../utils/use-transaction.js\";\nimport { useLaunchpadImageUpload } from \"../../utils/use-launchpad-image-upload.js\";\nimport { invalidatePortfolioCache } from \"../../utils/portfolio-cache.js\";\n\nconst DEFAULTS: EditionMintValues = {\n value: \"1\",\n recipient: \"\",\n name: \"\",\n description: \"\",\n external_url: \"\",\n ipType: \"NFT\",\n licenseType: \"CC BY-SA\",\n commercialUse: \"Yes\",\n derivatives: \"Share-Alike\",\n attribution: \"Required\",\n geographicScope: \"Worldwide\",\n aiPolicy: \"Not Allowed\",\n royalty: 0,\n};\n\nexport function EditionMint({ contract: rawContract, aside }: { contract: string; aside?: ReactNode }) {\n const app = useMedialaneApp();\n const walletAddress = app.walletAddress;\n const collectionAddress = normalizeAddress(\"STARKNET\", rawContract);\n const tx = useTransaction();\n const upload = useLaunchpadImageUpload({ successMessage: \"Image uploaded to IPFS\", failureMessage: \"Image upload failed\" });\n const { imagePreview, imageUri, imageUploading, uploadError, uploadSuccess, fileInputRef, handleImageSelect, clearImage } = upload;\n const [ownerCheck, setOwnerCheck] = useState<\"loading\" | \"ok\" | \"denied\">(\"loading\");\n const [formError, setFormError] = useState<string | null>(null);\n const [metadataResetKey, setMetadataResetKey] = useState(0);\n const [autoExternalUrl, setAutoExternalUrl] = useState(\"\");\n const metadataFieldsRef = useRef<MetadataField[]>([]);\n\n const form = useForm<EditionMintValues>({ resolver: zodResolver(editionMintSchema), defaultValues: DEFAULTS });\n\n useEffect(() => {\n if (walletAddress && !form.getValues(\"recipient\")) form.setValue(\"recipient\", walletAddress);\n }, [walletAddress, form]);\n\n useEffect(() => {\n const suggested = `https://medialane.io/collections/${collectionAddress}`;\n const current = form.getValues(\"external_url\");\n if (!current || current === autoExternalUrl) {\n form.setValue(\"external_url\", suggested, { shouldDirty: false });\n setAutoExternalUrl(suggested);\n }\n }, [autoExternalUrl, collectionAddress, form]);\n\n useEffect(() => {\n if (!walletAddress) return;\n app\n .getClient()\n .api.collections.get(collectionAddress)\n .then((data) => {\n const owner = data.owner ? normalizeAddress(\"STARKNET\", data.owner) : null;\n setOwnerCheck(owner === normalizeAddress(\"STARKNET\", walletAddress) ? \"ok\" : \"denied\");\n })\n .catch(() => setOwnerCheck(\"denied\"));\n }, [app, walletAddress, collectionAddress]);\n\n const uploadDocument = async (file: File) => {\n await app.ensureSignedIn?.();\n return (await uploadFileToIpfs(app.getClient().api, file, \"document\")).uri;\n };\n\n const handleAgain = () => {\n tx.reset();\n metadataFieldsRef.current = [];\n setMetadataResetKey((key) => key + 1);\n setAutoExternalUrl(\"\");\n clearImage();\n form.reset({ ...DEFAULTS, recipient: walletAddress ?? \"\" });\n };\n\n const onSubmit = (values: EditionMintValues) => {\n if (!imageUri) {\n setFormError(\"Upload an image before minting.\");\n return;\n }\n if (!walletAddress) return;\n setFormError(null);\n void tx.run(async (signer) => {\n await app.ensureSignedIn?.();\n const api = app.getClient().api;\n const pinned = await pinAssetMetadata(api, {\n name: values.name,\n description: values.description ?? \"\",\n imageUri,\n externalUrl: values.external_url,\n ipType: values.ipType,\n licenseType: values.licenseType,\n commercialUse: values.commercialUse,\n derivatives: values.derivatives,\n attribution: values.attribution,\n geographicScope: values.geographicScope,\n aiPolicy: values.aiPolicy,\n royalty: String(values.royalty),\n creator: walletAddress,\n templateTraits: metadataFieldsRef.current.filter((f) => f.traitType.trim() && f.value.trim()).map((f) => ({ traitType: f.traitType.trim(), value: f.value.trim() })),\n });\n await runIntentCalls(signer, () =>\n api.intents.create(\"mint\", {\n owner: walletAddress,\n recipient: values.recipient,\n collectionContract: collectionAddress,\n tokenUri: pinned.uri,\n value: values.value,\n royaltyBps: 0,\n }),\n );\n invalidatePortfolioCache(walletAddress);\n });\n };\n\n const mintedTokenId = tx.receipt ? mintedTokenIdFromReceipt(tx.receipt, collectionAddress) : null;\n\n return (\n <WalletRequired\n icon={Sparkles}\n iconClassName=\"text-brand-purple\"\n title=\"Secure your account to create\"\n description=\"Secure your account to mint tokens into a multi-editions collection.\"\n >\n {ownerCheck === \"denied\" ? (\n <div className=\"max-w-lg mx-auto px-4 pt-24 pb-8 text-center space-y-4\">\n <Sparkles className=\"h-10 w-10 text-muted-foreground mx-auto\" />\n <h1 className=\"text-2xl font-bold\">Not the owner</h1>\n <p className=\"text-muted-foreground\">Only the collection owner can mint tokens. Connect the wallet that deployed this collection.</p>\n <Button asChild variant=\"outline\">\n <Link href=\"/launchpad\">Back to Launchpad</Link>\n </Button>\n </div>\n ) : (\n <>\n <ClaimRouteShell\n icon={<Sparkles className=\"h-4 w-4 text-white\" />}\n title=\"Mint an Edition\"\n subtitle=\"Add a new piece to your collection — its details and authorship are saved permanently. Free to mint, and it's yours.\"\n headerAccessory={\n <div className=\"flex items-center gap-2 rounded-lg border border-border bg-background/60 px-3 py-2 max-w-full\">\n <span className=\"tabular-nums text-xs text-foreground/80 truncate\">Collection: {collectionAddress}</span>\n </div>\n }\n aside={\n <>\n <MedialaneCollectionCard\n image={imagePreview}\n name={form.watch(\"name\")}\n collection=\"Edition\"\n serial={Number(form.watch(\"value\")) > 1 ? `${form.watch(\"value\")} editions` : undefined}\n creator={walletAddress ? `${walletAddress.slice(0, 6)}…${walletAddress.slice(-4)}` : undefined}\n creatorHref={walletAddress ? profileHref({ address: walletAddress }) : undefined}\n />\n {aside}\n </>\n }\n >\n <Form {...form}>\n <form onSubmit={form.handleSubmit(onSubmit)} className=\"space-y-5\">\n <EditionMintFields\n form={form}\n imagePreview={imagePreview}\n imageUri={imageUri}\n imageUploading={imageUploading}\n mintDisabled={imageUploading || tx.phase !== \"idle\"}\n fileInputRef={fileInputRef}\n onImageSelect={handleImageSelect}\n onClearImage={clearImage}\n metadataResetKey={metadataResetKey}\n onMetadataFieldsChange={(fields) => { metadataFieldsRef.current = fields; }}\n uploadDocument={uploadDocument}\n />\n {uploadError && <p className=\"text-xs text-destructive mt-1\">{uploadError}</p>}\n {uploadSuccess && <p className=\"text-xs text-emerald-500 mt-1\">✓ {uploadSuccess}</p>}\n {formError && <p className=\"text-xs text-destructive mt-1\">{formError}</p>}\n </form>\n </Form>\n </ClaimRouteShell>\n\n <TransactionDialog tx={tx} title=\"Mint an edition\" workingLabel=\"Minting your edition…\" firstStepLabel=\"Upload metadata\">\n <CreationSuccess\n name={form.getValues(\"name\") || \"Your token\"}\n image={imagePreview}\n caption=\"Your edition is live\"\n primary={mintedTokenId ? { href: assetHref(\"STARKNET\", collectionAddress, mintedTokenId), label: \"View asset\" } : { href: \"/portfolio/assets\", label: \"View portfolio\" }}\n secondary={mintedTokenId ? { href: \"/portfolio/assets\", label: \"View portfolio\" } : undefined}\n onAgain={handleAgain}\n againLabel=\"Mint another\"\n >\n <RewardEarned actionType=\"mint_asset\" />\n </CreationSuccess>\n </TransactionDialog>\n </>\n )}\n </WalletRequired>\n );\n}\n"],"mappings":";AAmJQ,SAoBM,UAnBJ,KADF;AAjJR,SAAS,WAAW,QAAQ,gBAAgC;AAC5D,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,gBAAgB;AACzB,SAAS,WAAW,kBAAkB,mBAAmB;AACzD,SAAS,gCAAgC;AACzC,OAAO,UAAU;AACjB,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,u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gC;AAAA;AAAA,gBAAG;AAAA,iBAAc;AAAA,cAC/E,aAAa,oBAAC,OAAE,WAAU,iCAAiC,qBAAU;AAAA,eACxE,GACF;AAAA;AAAA,QACF;AAAA,QAEA,oBAAC,qBAAkB,IAAQ,OAAM,mBAAkB,cAAa,8BAAwB,gBAAe,mBACrG;AAAA,UAAC;AAAA;AAAA,YACC,MAAM,KAAK,UAAU,MAAM,KAAK;AAAA,YAChC,OAAO;AAAA,YACP,SAAQ;AAAA,YACR,SAAS,gBAAgB,EAAE,MAAM,UAAU,YAAY,mBAAmB,aAAa,GAAG,OAAO,aAAa,IAAI,EAAE,MAAM,qBAAqB,OAAO,iBAAiB;AAAA,YACvK,WAAW,gBAAgB,EAAE,MAAM,qBAAqB,OAAO,iBAAiB,IAAI;AAAA,YACpF,SAAS;AAAA,YACT,YAAW;AAAA,YAEX,8BAAC,gBAAa,YAAW,cAAa;AAAA;AAAA,QACxC,GACF;AAAA,SACF;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
package/dist/index.cjs CHANGED
@@ -174,6 +174,7 @@ __export(index_exports, {
174
174
  EDITIONS_PRESET: () => import_collection_create_presets.EDITIONS_PRESET,
175
175
  EMBED_PLATFORM_META: () => import_ip_templates.EMBED_PLATFORM_META,
176
176
  EMPTY_SPONSORSHIP_TERMS: () => import_license_terms_builder.EMPTY_SPONSORSHIP_TERMS,
177
+ EditionMint: () => import_edition_mint.EditionMint,
177
178
  EditionsPage: () => import_editions_page.EditionsPage,
178
179
  EmailCodeEntry: () => import_email_code_entry.EmailCodeEntry,
179
180
  EmptyOrError: () => import_empty_or_error.EmptyOrError,
@@ -725,6 +726,7 @@ var import_tier_mint_form = require("./components/launchpad/tier-mint-form.js");
725
726
  var import_tier_mint_presets = require("./components/launchpad/tier-mint-presets.js");
726
727
  var import_single_edition_mint = require("./components/launchpad/single-edition-mint.js");
727
728
  var import_collection_picker = require("./components/launchpad/collection-picker.js");
729
+ var import_edition_mint = require("./components/launchpad/edition-mint.js");
728
730
  var import_wallet_required = require("./components/wallet-required.js");
729
731
  var import_claim_route_shell = require("./components/claim-route-shell.js");
730
732
  var import_use_launchpad_image_upload = require("./utils/use-launchpad-image-upload.js");
@@ -972,6 +974,7 @@ var import_asset_accents = require("./utils/asset-accents.js");
972
974
  EDITIONS_PRESET,
973
975
  EMBED_PLATFORM_META,
974
976
  EMPTY_SPONSORSHIP_TERMS,
977
+ EditionMint,
975
978
  EditionsPage,
976
979
  EmailCodeEntry,
977
980
  EmptyOrError,