@medialane/ui 0.242.0 → 0.244.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/launchpad/pop-create-fields.cjs +295 -0
- package/dist/components/launchpad/pop-create-fields.cjs.map +1 -0
- package/dist/components/launchpad/pop-create-fields.d.cts +25 -0
- package/dist/components/launchpad/pop-create-fields.d.ts +25 -0
- package/dist/components/launchpad/pop-create-fields.js +273 -0
- package/dist/components/launchpad/pop-create-fields.js.map +1 -0
- package/dist/components/launchpad/pop-create-schema.cjs +71 -0
- package/dist/components/launchpad/pop-create-schema.cjs.map +1 -0
- package/dist/components/launchpad/pop-create-schema.d.cts +41 -0
- package/dist/components/launchpad/pop-create-schema.d.ts +41 -0
- package/dist/components/launchpad/pop-create-schema.js +37 -0
- package/dist/components/launchpad/pop-create-schema.js.map +1 -0
- package/dist/components/launchpad/pop-create.cjs +191 -0
- package/dist/components/launchpad/pop-create.cjs.map +1 -0
- package/dist/components/launchpad/pop-create.d.cts +8 -0
- package/dist/components/launchpad/pop-create.d.ts +8 -0
- package/dist/components/launchpad/pop-create.js +167 -0
- package/dist/components/launchpad/pop-create.js.map +1 -0
- package/dist/components/launchpad/sponsorship-create.cjs +269 -0
- package/dist/components/launchpad/sponsorship-create.cjs.map +1 -0
- package/dist/components/launchpad/sponsorship-create.d.cts +8 -0
- package/dist/components/launchpad/sponsorship-create.d.ts +8 -0
- package/dist/components/launchpad/sponsorship-create.js +245 -0
- package/dist/components/launchpad/sponsorship-create.js.map +1 -0
- package/dist/index.cjs +6 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var sponsorship_create_exports = {};
|
|
21
|
+
__export(sponsorship_create_exports, {
|
|
22
|
+
SponsorshipCreate: () => SponsorshipCreate
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(sponsorship_create_exports);
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_lucide_react = require("lucide-react");
|
|
28
|
+
var import_sdk = require("@medialane/sdk");
|
|
29
|
+
var import_button = require("../button.js");
|
|
30
|
+
var import_asset_picker = require("../asset-picker.js");
|
|
31
|
+
var import_asset_search_picker = require("../asset-search-picker.js");
|
|
32
|
+
var import_license_terms_builder = require("../license-terms-builder.js");
|
|
33
|
+
var import_claim_route_shell = require("../claim-route-shell.js");
|
|
34
|
+
var import_creation_success = require("../creation-success.js");
|
|
35
|
+
var import_transaction_dialog = require("../transaction-dialog.js");
|
|
36
|
+
var import_wallet_required = require("../wallet-required.js");
|
|
37
|
+
var import_medialane_app = require("../medialane-app.js");
|
|
38
|
+
var import_reward_earned = require("../rewards/reward-earned.js");
|
|
39
|
+
var import_run_intent_calls = require("../../utils/run-intent-calls.js");
|
|
40
|
+
var import_ipfs_upload = require("../../utils/ipfs-upload.js");
|
|
41
|
+
var import_use_image_url = require("../../utils/use-image-url.js");
|
|
42
|
+
var import_use_tokens = require("../../utils/use-tokens.js");
|
|
43
|
+
var import_use_sponsorship = require("../../utils/use-sponsorship.js");
|
|
44
|
+
var import_use_transaction = require("../../utils/use-transaction.js");
|
|
45
|
+
var import_address = require("../../utils/address.js");
|
|
46
|
+
const TOKEN_SYMBOLS = import_sdk.SUPPORTED_TOKENS.filter((t) => t.listable).map((t) => t.symbol);
|
|
47
|
+
function PendingProposalsPanel({ nftContract }) {
|
|
48
|
+
const app = (0, import_medialane_app.useMedialaneApp)();
|
|
49
|
+
const walletAddress = app.walletAddress;
|
|
50
|
+
const { proposals, isLoading, mutate } = (0, import_use_sponsorship.usePendingProposalsForAsset)(nftContract);
|
|
51
|
+
const tx = (0, import_use_transaction.useTransaction)();
|
|
52
|
+
const [activeId, setActiveId] = (0, import_react.useState)(null);
|
|
53
|
+
const busy = tx.phase === "preparing" || tx.phase === "submitting" || tx.phase === "confirming";
|
|
54
|
+
const respond = (proposalId, decision) => {
|
|
55
|
+
if (!walletAddress) return;
|
|
56
|
+
setActiveId(proposalId);
|
|
57
|
+
void tx.run(async (signer) => {
|
|
58
|
+
const api = app.getClient().api;
|
|
59
|
+
await (0, import_run_intent_calls.runIntentCalls)(
|
|
60
|
+
signer,
|
|
61
|
+
() => decision === "accept" ? api.intents.create("sponsorship-proposal-accept", { owner: walletAddress, proposalId }) : api.intents.create("sponsorship-proposal-reject", { owner: walletAddress, proposalId })
|
|
62
|
+
);
|
|
63
|
+
await mutate();
|
|
64
|
+
}).finally(() => setActiveId(null));
|
|
65
|
+
};
|
|
66
|
+
if (isLoading || proposals.length === 0) return null;
|
|
67
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rounded-xl border border-border bg-card p-4 space-y-3", children: [
|
|
68
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm font-semibold", children: "Pending proposals" }),
|
|
69
|
+
proposals.map((p) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center justify-between gap-3 text-sm", children: [
|
|
70
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "truncate text-muted-foreground", children: [
|
|
71
|
+
(0, import_address.shortenAddress)(p.proposer),
|
|
72
|
+
" \u2014 ",
|
|
73
|
+
p.amount
|
|
74
|
+
] }),
|
|
75
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex gap-2 shrink-0", children: [
|
|
76
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_button.Button, { size: "sm", variant: "outline", disabled: busy, onClick: () => respond(p.proposalId, "reject"), children: [
|
|
77
|
+
busy && activeId === p.proposalId ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Loader2, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.X, { className: "h-3 w-3" }),
|
|
78
|
+
"Decline"
|
|
79
|
+
] }),
|
|
80
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_button.Button, { size: "sm", className: "bg-brand-rose hover:brightness-110 text-white", disabled: busy, onClick: () => respond(p.proposalId, "accept"), children: [
|
|
81
|
+
busy && activeId === p.proposalId ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Loader2, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.CheckCircle2, { className: "h-3 w-3" }),
|
|
82
|
+
"Accept"
|
|
83
|
+
] })
|
|
84
|
+
] })
|
|
85
|
+
] }, p.proposalId)),
|
|
86
|
+
tx.phase === "error" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-2 text-xs text-destructive", role: "alert", children: [
|
|
87
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.AlertCircle, { className: "h-3.5 w-3.5" }),
|
|
88
|
+
tx.error,
|
|
89
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "underline", onClick: tx.reset, children: "Dismiss" })
|
|
90
|
+
] })
|
|
91
|
+
] });
|
|
92
|
+
}
|
|
93
|
+
function SponsorshipCreate({ aside }) {
|
|
94
|
+
const app = (0, import_medialane_app.useMedialaneApp)();
|
|
95
|
+
const walletAddress = app.walletAddress;
|
|
96
|
+
const resolveImage = (0, import_use_image_url.useImageUrl)();
|
|
97
|
+
const tx = (0, import_use_transaction.useTransaction)();
|
|
98
|
+
const [formError, setFormError] = (0, import_react.useState)(null);
|
|
99
|
+
const [mode, setMode] = (0, import_react.useState)("propose");
|
|
100
|
+
const [selectedAsset, setSelectedAsset] = (0, import_react.useState)(null);
|
|
101
|
+
const [proposeAsset, setProposeAsset] = (0, import_react.useState)(null);
|
|
102
|
+
const [terms, setTerms] = (0, import_react.useState)({ ...import_license_terms_builder.EMPTY_SPONSORSHIP_TERMS, paymentTokenSymbol: "USDC" });
|
|
103
|
+
const busy = tx.phase !== "idle";
|
|
104
|
+
const { tokens: ownedTokens, isLoading: assetsLoading } = (0, import_use_tokens.useTokensByOwner)(walletAddress ?? null, 1, 100);
|
|
105
|
+
const ownedAssets = ownedTokens.map((t) => ({
|
|
106
|
+
contractAddress: t.contractAddress,
|
|
107
|
+
tokenId: t.tokenId,
|
|
108
|
+
name: t.metadata?.name ?? `Token #${t.tokenId}`,
|
|
109
|
+
image: resolveImage(t.metadata?.image)
|
|
110
|
+
}));
|
|
111
|
+
const searchAssets = async (query) => {
|
|
112
|
+
const res = await app.getClient().api.search(query, 16);
|
|
113
|
+
return res.data.tokens.map((t) => ({
|
|
114
|
+
contractAddress: t.contractAddress,
|
|
115
|
+
tokenId: t.tokenId,
|
|
116
|
+
name: t.name ?? `Token #${t.tokenId}`,
|
|
117
|
+
image: resolveImage(t.image)
|
|
118
|
+
}));
|
|
119
|
+
};
|
|
120
|
+
const chosen = mode === "offer" ? selectedAsset : proposeAsset;
|
|
121
|
+
const onSubmit = () => {
|
|
122
|
+
setFormError(null);
|
|
123
|
+
if (!walletAddress) return setFormError("Your account isn't ready yet. Refresh the page and try again.");
|
|
124
|
+
if (!chosen) return setFormError(mode === "offer" ? "Choose which asset you're offering." : "Search for the asset you want to sponsor, then pick it.");
|
|
125
|
+
if (!terms.amount || Number(terms.amount) <= 0) return setFormError("Add an amount before continuing.");
|
|
126
|
+
const token = (0, import_sdk.getTokenBySymbol)(terms.paymentTokenSymbol);
|
|
127
|
+
if (!token) return setFormError("Pick a currency.");
|
|
128
|
+
const durationDays = (0, import_license_terms_builder.toDurationDays)(terms);
|
|
129
|
+
if (!durationDays) return setFormError("Choose how long the license should last.");
|
|
130
|
+
void tx.run(async (signer) => {
|
|
131
|
+
await app.ensureSignedIn?.();
|
|
132
|
+
const api = app.getClient().api;
|
|
133
|
+
const licenseTermsUri = await (0, import_ipfs_upload.uploadJsonToIpfs)(api, (0, import_license_terms_builder.toLicenseMetadata)(terms));
|
|
134
|
+
const amount = BigInt(Math.round(Number(terms.amount) * 10 ** token.decimals)).toString();
|
|
135
|
+
const duration = durationDays * 86400;
|
|
136
|
+
const royaltyBps = Math.round(Number(terms.royaltyPercent || "0") * 100);
|
|
137
|
+
await (0, import_run_intent_calls.runIntentCalls)(
|
|
138
|
+
signer,
|
|
139
|
+
() => mode === "offer" ? api.intents.create("sponsorship-offer", {
|
|
140
|
+
author: walletAddress,
|
|
141
|
+
nftContract: chosen.contractAddress,
|
|
142
|
+
tokenId: chosen.tokenId,
|
|
143
|
+
minAmount: amount,
|
|
144
|
+
duration,
|
|
145
|
+
paymentToken: token.address,
|
|
146
|
+
licenseTermsUri,
|
|
147
|
+
transferable: terms.transferable,
|
|
148
|
+
royaltyBps
|
|
149
|
+
}) : api.intents.create("sponsorship-proposal", {
|
|
150
|
+
proposer: walletAddress,
|
|
151
|
+
nftContract: chosen.contractAddress,
|
|
152
|
+
tokenId: chosen.tokenId,
|
|
153
|
+
amount,
|
|
154
|
+
duration,
|
|
155
|
+
paymentToken: token.address,
|
|
156
|
+
licenseTermsUri,
|
|
157
|
+
transferable: terms.transferable,
|
|
158
|
+
royaltyBps
|
|
159
|
+
})
|
|
160
|
+
);
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
const handleAgain = () => {
|
|
164
|
+
tx.reset();
|
|
165
|
+
setSelectedAsset(null);
|
|
166
|
+
setProposeAsset(null);
|
|
167
|
+
setTerms({ ...import_license_terms_builder.EMPTY_SPONSORSHIP_TERMS, paymentTokenSymbol: "USDC" });
|
|
168
|
+
};
|
|
169
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
170
|
+
import_wallet_required.WalletRequired,
|
|
171
|
+
{
|
|
172
|
+
icon: import_lucide_react.Handshake,
|
|
173
|
+
iconClassName: "text-brand-rose",
|
|
174
|
+
title: "Secure your account to set up a sponsorship",
|
|
175
|
+
description: "Secure your account to publish onchain.",
|
|
176
|
+
children: [
|
|
177
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
178
|
+
import_claim_route_shell.ClaimRouteShell,
|
|
179
|
+
{
|
|
180
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Handshake, { className: "h-4 w-4 text-white" }),
|
|
181
|
+
title: "Set up a sponsorship",
|
|
182
|
+
subtitle: "Found IP you'd like to back? Propose terms directly to its owner. Own something worth sponsoring? Post it and let sponsors bid.",
|
|
183
|
+
aside,
|
|
184
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-6", children: [
|
|
185
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "inline-flex rounded-full border border-border p-1 bg-card", children: ["offer", "propose"].map((m) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
186
|
+
"button",
|
|
187
|
+
{
|
|
188
|
+
type: "button",
|
|
189
|
+
onClick: () => setMode(m),
|
|
190
|
+
className: mode === m ? "px-4 py-1.5 rounded-full text-sm font-semibold bg-gradient-to-r from-brand-purple to-brand-blue text-white" : "px-4 py-1.5 rounded-full text-sm font-semibold text-muted-foreground",
|
|
191
|
+
children: m === "offer" ? "Offer my asset" : "Propose to sponsor"
|
|
192
|
+
},
|
|
193
|
+
m
|
|
194
|
+
)) }),
|
|
195
|
+
mode === "offer" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-2", children: [
|
|
196
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm font-semibold", children: "Pick an asset you own" }),
|
|
197
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
198
|
+
import_asset_picker.AssetPicker,
|
|
199
|
+
{
|
|
200
|
+
assets: ownedAssets,
|
|
201
|
+
isLoading: assetsLoading,
|
|
202
|
+
selected: selectedAsset,
|
|
203
|
+
onSelect: setSelectedAsset,
|
|
204
|
+
emptyStateHref: "/launchpad/single-editions",
|
|
205
|
+
emptyStateLabel: "Create one"
|
|
206
|
+
}
|
|
207
|
+
),
|
|
208
|
+
selectedAsset ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PendingProposalsPanel, { nftContract: selectedAsset.contractAddress }) : null
|
|
209
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-2", children: [
|
|
210
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm font-semibold", children: "Which asset do you want to sponsor?" }),
|
|
211
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_asset_search_picker.AssetSearchPicker, { search: searchAssets, selected: proposeAsset, onSelect: setProposeAsset, placeholder: "Search by asset name or creator" })
|
|
212
|
+
] }),
|
|
213
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pt-2 border-t border-border/30", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
214
|
+
import_license_terms_builder.LicenseTermsBuilder,
|
|
215
|
+
{
|
|
216
|
+
value: terms,
|
|
217
|
+
onChange: setTerms,
|
|
218
|
+
tokenOptions: TOKEN_SYMBOLS,
|
|
219
|
+
amountLabel: mode === "offer" ? "Minimum accepted bid" : "Amount you'll pay",
|
|
220
|
+
disabled: busy
|
|
221
|
+
}
|
|
222
|
+
) }),
|
|
223
|
+
formError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { role: "alert", className: "text-sm text-destructive", children: formError }),
|
|
224
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "btn-border-animated p-[1px] rounded-2xl", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
225
|
+
"button",
|
|
226
|
+
{
|
|
227
|
+
type: "button",
|
|
228
|
+
disabled: busy,
|
|
229
|
+
onClick: onSubmit,
|
|
230
|
+
className: "w-full h-12 rounded-[15px] flex items-center justify-center gap-2 text-base font-semibold text-white bg-transparent transition-all hover:brightness-110 active:scale-[0.98] disabled:opacity-50",
|
|
231
|
+
children: [
|
|
232
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.Handshake, { className: "h-4 w-4" }),
|
|
233
|
+
mode === "offer" ? "Create Offer" : "Send proposal"
|
|
234
|
+
]
|
|
235
|
+
}
|
|
236
|
+
) })
|
|
237
|
+
] })
|
|
238
|
+
}
|
|
239
|
+
),
|
|
240
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
241
|
+
import_transaction_dialog.TransactionDialog,
|
|
242
|
+
{
|
|
243
|
+
tx,
|
|
244
|
+
title: mode === "offer" ? "Create sponsorship offer" : "Send proposal",
|
|
245
|
+
workingLabel: mode === "offer" ? "Creating your sponsorship offer\u2026" : "Sending your proposal\u2026",
|
|
246
|
+
firstStepLabel: "Upload license terms",
|
|
247
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
248
|
+
import_creation_success.CreationSuccess,
|
|
249
|
+
{
|
|
250
|
+
name: chosen?.name ?? "Your sponsorship",
|
|
251
|
+
image: chosen?.image ?? null,
|
|
252
|
+
caption: mode === "offer" ? "Your offer is live" : "Your proposal is sent",
|
|
253
|
+
primary: { href: "/launchpad/sponsorship", label: "Back to Sponsorship launchpad" },
|
|
254
|
+
onAgain: handleAgain,
|
|
255
|
+
againLabel: "Create another",
|
|
256
|
+
children: mode === "offer" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_reward_earned.RewardEarned, { actionType: "create_sponsorship_offer" })
|
|
257
|
+
}
|
|
258
|
+
)
|
|
259
|
+
}
|
|
260
|
+
)
|
|
261
|
+
]
|
|
262
|
+
}
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
266
|
+
0 && (module.exports = {
|
|
267
|
+
SponsorshipCreate
|
|
268
|
+
});
|
|
269
|
+
//# sourceMappingURL=sponsorship-create.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/launchpad/sponsorship-create.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState, type ReactNode } from \"react\";\nimport { AlertCircle, CheckCircle2, Handshake, Loader2, X } from \"lucide-react\";\nimport { SUPPORTED_TOKENS, getTokenBySymbol } from \"@medialane/sdk\";\nimport { Button } from \"../button.js\";\nimport { AssetPicker, type OwnedAsset } from \"../asset-picker.js\";\nimport { AssetSearchPicker } from \"../asset-search-picker.js\";\nimport { LicenseTermsBuilder, EMPTY_SPONSORSHIP_TERMS, toDurationDays, toLicenseMetadata, type SponsorshipTerms } from \"../license-terms-builder.js\";\nimport { ClaimRouteShell } from \"../claim-route-shell.js\";\nimport { CreationSuccess } from \"../creation-success.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 { runIntentCalls } from \"../../utils/run-intent-calls.js\";\nimport { uploadJsonToIpfs } from \"../../utils/ipfs-upload.js\";\nimport { useImageUrl } from \"../../utils/use-image-url.js\";\nimport { useTokensByOwner } from \"../../utils/use-tokens.js\";\nimport { usePendingProposalsForAsset } from \"../../utils/use-sponsorship.js\";\nimport { useTransaction } from \"../../utils/use-transaction.js\";\nimport { shortenAddress } from \"../../utils/address.js\";\n\ntype Mode = \"offer\" | \"propose\";\n\nconst TOKEN_SYMBOLS = SUPPORTED_TOKENS.filter((t) => t.listable).map((t) => t.symbol);\n\nfunction PendingProposalsPanel({ nftContract }: { nftContract: string }) {\n const app = useMedialaneApp();\n const walletAddress = app.walletAddress;\n const { proposals, isLoading, mutate } = usePendingProposalsForAsset(nftContract);\n const tx = useTransaction();\n const [activeId, setActiveId] = useState<string | null>(null);\n const busy = tx.phase === \"preparing\" || tx.phase === \"submitting\" || tx.phase === \"confirming\";\n\n const respond = (proposalId: string, decision: \"accept\" | \"reject\") => {\n if (!walletAddress) return;\n setActiveId(proposalId);\n void tx\n .run(async (signer) => {\n const api = app.getClient().api;\n await runIntentCalls(signer, () =>\n decision === \"accept\"\n ? api.intents.create(\"sponsorship-proposal-accept\", { owner: walletAddress, proposalId })\n : api.intents.create(\"sponsorship-proposal-reject\", { owner: walletAddress, proposalId }),\n );\n await mutate();\n })\n .finally(() => setActiveId(null));\n };\n\n if (isLoading || proposals.length === 0) return null;\n\n return (\n <div className=\"rounded-xl border border-border bg-card p-4 space-y-3\">\n <p className=\"text-sm font-semibold\">Pending proposals</p>\n {proposals.map((p) => (\n <div key={p.proposalId} className=\"flex items-center justify-between gap-3 text-sm\">\n <span className=\"truncate text-muted-foreground\">{shortenAddress(p.proposer)} — {p.amount}</span>\n <div className=\"flex gap-2 shrink-0\">\n <Button size=\"sm\" variant=\"outline\" disabled={busy} onClick={() => respond(p.proposalId, \"reject\")}>\n {busy && activeId === p.proposalId ? <Loader2 className=\"h-3 w-3 animate-spin\" /> : <X className=\"h-3 w-3\" />}\n Decline\n </Button>\n <Button size=\"sm\" className=\"bg-brand-rose hover:brightness-110 text-white\" disabled={busy} onClick={() => respond(p.proposalId, \"accept\")}>\n {busy && activeId === p.proposalId ? <Loader2 className=\"h-3 w-3 animate-spin\" /> : <CheckCircle2 className=\"h-3 w-3\" />}\n Accept\n </Button>\n </div>\n </div>\n ))}\n {tx.phase === \"error\" && (\n <div className=\"flex items-center gap-2 text-xs text-destructive\" role=\"alert\">\n <AlertCircle className=\"h-3.5 w-3.5\" />\n {tx.error}\n <button type=\"button\" className=\"underline\" onClick={tx.reset}>Dismiss</button>\n </div>\n )}\n </div>\n );\n}\n\nexport function SponsorshipCreate({ aside }: { aside?: ReactNode }) {\n const app = useMedialaneApp();\n const walletAddress = app.walletAddress;\n const resolveImage = useImageUrl();\n const tx = useTransaction();\n const [formError, setFormError] = useState<string | null>(null);\n const [mode, setMode] = useState<Mode>(\"propose\");\n const [selectedAsset, setSelectedAsset] = useState<OwnedAsset | null>(null);\n const [proposeAsset, setProposeAsset] = useState<OwnedAsset | null>(null);\n const [terms, setTerms] = useState<SponsorshipTerms>({ ...EMPTY_SPONSORSHIP_TERMS, paymentTokenSymbol: \"USDC\" });\n const busy = tx.phase !== \"idle\";\n\n const { tokens: ownedTokens, isLoading: assetsLoading } = useTokensByOwner(walletAddress ?? null, 1, 100);\n const ownedAssets: OwnedAsset[] = ownedTokens.map((t) => ({\n contractAddress: t.contractAddress,\n tokenId: t.tokenId,\n name: t.metadata?.name ?? `Token #${t.tokenId}`,\n image: resolveImage(t.metadata?.image),\n }));\n\n const searchAssets = async (query: string): Promise<OwnedAsset[]> => {\n const res = await app.getClient().api.search(query, 16);\n return res.data.tokens.map((t) => ({\n contractAddress: t.contractAddress,\n tokenId: t.tokenId,\n name: t.name ?? `Token #${t.tokenId}`,\n image: resolveImage(t.image),\n }));\n };\n\n const chosen = mode === \"offer\" ? selectedAsset : proposeAsset;\n\n const onSubmit = () => {\n setFormError(null);\n if (!walletAddress) return setFormError(\"Your account isn't ready yet. Refresh the page and try again.\");\n if (!chosen) return setFormError(mode === \"offer\" ? \"Choose which asset you're offering.\" : \"Search for the asset you want to sponsor, then pick it.\");\n if (!terms.amount || Number(terms.amount) <= 0) return setFormError(\"Add an amount before continuing.\");\n const token = getTokenBySymbol(terms.paymentTokenSymbol);\n if (!token) return setFormError(\"Pick a currency.\");\n const durationDays = toDurationDays(terms);\n if (!durationDays) return setFormError(\"Choose how long the license should last.\");\n\n void tx.run(async (signer) => {\n await app.ensureSignedIn?.();\n const api = app.getClient().api;\n const licenseTermsUri = await uploadJsonToIpfs(api, toLicenseMetadata(terms));\n const amount = BigInt(Math.round(Number(terms.amount) * 10 ** token.decimals)).toString();\n const duration = durationDays * 86400;\n const royaltyBps = Math.round(Number(terms.royaltyPercent || \"0\") * 100);\n await runIntentCalls(signer, () =>\n mode === \"offer\"\n ? api.intents.create(\"sponsorship-offer\", {\n author: walletAddress, nftContract: chosen.contractAddress, tokenId: chosen.tokenId, minAmount: amount,\n duration, paymentToken: token.address, licenseTermsUri, transferable: terms.transferable, royaltyBps,\n })\n : api.intents.create(\"sponsorship-proposal\", {\n proposer: walletAddress, nftContract: chosen.contractAddress, tokenId: chosen.tokenId, amount,\n duration, paymentToken: token.address, licenseTermsUri, transferable: terms.transferable, royaltyBps,\n }),\n );\n });\n };\n\n const handleAgain = () => {\n tx.reset();\n setSelectedAsset(null);\n setProposeAsset(null);\n setTerms({ ...EMPTY_SPONSORSHIP_TERMS, paymentTokenSymbol: \"USDC\" });\n };\n\n return (\n <WalletRequired\n icon={Handshake}\n iconClassName=\"text-brand-rose\"\n title=\"Secure your account to set up a sponsorship\"\n description=\"Secure your account to publish onchain.\"\n >\n <ClaimRouteShell\n icon={<Handshake className=\"h-4 w-4 text-white\" />}\n title=\"Set up a sponsorship\"\n subtitle=\"Found IP you'd like to back? Propose terms directly to its owner. Own something worth sponsoring? Post it and let sponsors bid.\"\n aside={aside}\n >\n <div className=\"space-y-6\">\n <div className=\"inline-flex rounded-full border border-border p-1 bg-card\">\n {([\"offer\", \"propose\"] as const).map((m) => (\n <button\n key={m}\n type=\"button\"\n onClick={() => setMode(m)}\n className={\n mode === m\n ? \"px-4 py-1.5 rounded-full text-sm font-semibold bg-gradient-to-r from-brand-purple to-brand-blue text-white\"\n : \"px-4 py-1.5 rounded-full text-sm font-semibold text-muted-foreground\"\n }\n >\n {m === \"offer\" ? \"Offer my asset\" : \"Propose to sponsor\"}\n </button>\n ))}\n </div>\n\n {mode === \"offer\" ? (\n <div className=\"space-y-2\">\n <p className=\"text-sm font-semibold\">Pick an asset you own</p>\n <AssetPicker\n assets={ownedAssets}\n isLoading={assetsLoading}\n selected={selectedAsset}\n onSelect={setSelectedAsset}\n emptyStateHref=\"/launchpad/single-editions\"\n emptyStateLabel=\"Create one\"\n />\n {selectedAsset ? <PendingProposalsPanel nftContract={selectedAsset.contractAddress} /> : null}\n </div>\n ) : (\n <div className=\"space-y-2\">\n <p className=\"text-sm font-semibold\">Which asset do you want to sponsor?</p>\n <AssetSearchPicker search={searchAssets} selected={proposeAsset} onSelect={setProposeAsset} placeholder=\"Search by asset name or creator\" />\n </div>\n )}\n\n <div className=\"pt-2 border-t border-border/30\">\n <LicenseTermsBuilder\n value={terms}\n onChange={setTerms}\n tokenOptions={TOKEN_SYMBOLS}\n amountLabel={mode === \"offer\" ? \"Minimum accepted bid\" : \"Amount you'll pay\"}\n disabled={busy}\n />\n </div>\n\n {formError && <p role=\"alert\" className=\"text-sm text-destructive\">{formError}</p>}\n\n <div className=\"btn-border-animated p-[1px] rounded-2xl\">\n <button\n type=\"button\"\n disabled={busy}\n onClick={onSubmit}\n className=\"w-full h-12 rounded-[15px] flex items-center justify-center gap-2 text-base font-semibold text-white bg-transparent transition-all hover:brightness-110 active:scale-[0.98] disabled:opacity-50\"\n >\n <Handshake className=\"h-4 w-4\" />\n {mode === \"offer\" ? \"Create Offer\" : \"Send proposal\"}\n </button>\n </div>\n </div>\n </ClaimRouteShell>\n\n <TransactionDialog\n tx={tx}\n title={mode === \"offer\" ? \"Create sponsorship offer\" : \"Send proposal\"}\n workingLabel={mode === \"offer\" ? \"Creating your sponsorship offer…\" : \"Sending your proposal…\"}\n firstStepLabel=\"Upload license terms\"\n >\n <CreationSuccess\n name={chosen?.name ?? \"Your sponsorship\"}\n image={chosen?.image ?? null}\n caption={mode === \"offer\" ? \"Your offer is live\" : \"Your proposal is sent\"}\n primary={{ href: \"/launchpad/sponsorship\", label: \"Back to Sponsorship launchpad\" }}\n onAgain={handleAgain}\n againLabel=\"Create another\"\n >\n {mode === \"offer\" && <RewardEarned actionType=\"create_sponsorship_offer\" />}\n </CreationSuccess>\n </TransactionDialog>\n </WalletRequired>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAuDM;AArDN,mBAAyC;AACzC,0BAAiE;AACjE,iBAAmD;AACnD,oBAAuB;AACvB,0BAA6C;AAC7C,iCAAkC;AAClC,mCAAuH;AACvH,+BAAgC;AAChC,8BAAgC;AAChC,gCAAkC;AAClC,6BAA+B;AAC/B,2BAAgC;AAChC,2BAA6B;AAC7B,8BAA+B;AAC/B,yBAAiC;AACjC,2BAA4B;AAC5B,wBAAiC;AACjC,6BAA4C;AAC5C,6BAA+B;AAC/B,qBAA+B;AAI/B,MAAM,gBAAgB,4BAAiB,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM;AAEpF,SAAS,sBAAsB,EAAE,YAAY,GAA4B;AACvE,QAAM,UAAM,sCAAgB;AAC5B,QAAM,gBAAgB,IAAI;AAC1B,QAAM,EAAE,WAAW,WAAW,OAAO,QAAI,oDAA4B,WAAW;AAChF,QAAM,SAAK,uCAAe;AAC1B,QAAM,CAAC,UAAU,WAAW,QAAI,uBAAwB,IAAI;AAC5D,QAAM,OAAO,GAAG,UAAU,eAAe,GAAG,UAAU,gBAAgB,GAAG,UAAU;AAEnF,QAAM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
|
|
4
|
+
import { AlertCircle, CheckCircle2, Handshake, Loader2, X } from "lucide-react";
|
|
5
|
+
import { SUPPORTED_TOKENS, getTokenBySymbol } from "@medialane/sdk";
|
|
6
|
+
import { Button } from "../button.js";
|
|
7
|
+
import { AssetPicker } from "../asset-picker.js";
|
|
8
|
+
import { AssetSearchPicker } from "../asset-search-picker.js";
|
|
9
|
+
import { LicenseTermsBuilder, EMPTY_SPONSORSHIP_TERMS, toDurationDays, toLicenseMetadata } from "../license-terms-builder.js";
|
|
10
|
+
import { ClaimRouteShell } from "../claim-route-shell.js";
|
|
11
|
+
import { CreationSuccess } from "../creation-success.js";
|
|
12
|
+
import { TransactionDialog } from "../transaction-dialog.js";
|
|
13
|
+
import { WalletRequired } from "../wallet-required.js";
|
|
14
|
+
import { useMedialaneApp } from "../medialane-app.js";
|
|
15
|
+
import { RewardEarned } from "../rewards/reward-earned.js";
|
|
16
|
+
import { runIntentCalls } from "../../utils/run-intent-calls.js";
|
|
17
|
+
import { uploadJsonToIpfs } from "../../utils/ipfs-upload.js";
|
|
18
|
+
import { useImageUrl } from "../../utils/use-image-url.js";
|
|
19
|
+
import { useTokensByOwner } from "../../utils/use-tokens.js";
|
|
20
|
+
import { usePendingProposalsForAsset } from "../../utils/use-sponsorship.js";
|
|
21
|
+
import { useTransaction } from "../../utils/use-transaction.js";
|
|
22
|
+
import { shortenAddress } from "../../utils/address.js";
|
|
23
|
+
const TOKEN_SYMBOLS = SUPPORTED_TOKENS.filter((t) => t.listable).map((t) => t.symbol);
|
|
24
|
+
function PendingProposalsPanel({ nftContract }) {
|
|
25
|
+
const app = useMedialaneApp();
|
|
26
|
+
const walletAddress = app.walletAddress;
|
|
27
|
+
const { proposals, isLoading, mutate } = usePendingProposalsForAsset(nftContract);
|
|
28
|
+
const tx = useTransaction();
|
|
29
|
+
const [activeId, setActiveId] = useState(null);
|
|
30
|
+
const busy = tx.phase === "preparing" || tx.phase === "submitting" || tx.phase === "confirming";
|
|
31
|
+
const respond = (proposalId, decision) => {
|
|
32
|
+
if (!walletAddress) return;
|
|
33
|
+
setActiveId(proposalId);
|
|
34
|
+
void tx.run(async (signer) => {
|
|
35
|
+
const api = app.getClient().api;
|
|
36
|
+
await runIntentCalls(
|
|
37
|
+
signer,
|
|
38
|
+
() => decision === "accept" ? api.intents.create("sponsorship-proposal-accept", { owner: walletAddress, proposalId }) : api.intents.create("sponsorship-proposal-reject", { owner: walletAddress, proposalId })
|
|
39
|
+
);
|
|
40
|
+
await mutate();
|
|
41
|
+
}).finally(() => setActiveId(null));
|
|
42
|
+
};
|
|
43
|
+
if (isLoading || proposals.length === 0) return null;
|
|
44
|
+
return /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-border bg-card p-4 space-y-3", children: [
|
|
45
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-semibold", children: "Pending proposals" }),
|
|
46
|
+
proposals.map((p) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3 text-sm", children: [
|
|
47
|
+
/* @__PURE__ */ jsxs("span", { className: "truncate text-muted-foreground", children: [
|
|
48
|
+
shortenAddress(p.proposer),
|
|
49
|
+
" \u2014 ",
|
|
50
|
+
p.amount
|
|
51
|
+
] }),
|
|
52
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-2 shrink-0", children: [
|
|
53
|
+
/* @__PURE__ */ jsxs(Button, { size: "sm", variant: "outline", disabled: busy, onClick: () => respond(p.proposalId, "reject"), children: [
|
|
54
|
+
busy && activeId === p.proposalId ? /* @__PURE__ */ jsx(Loader2, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }),
|
|
55
|
+
"Decline"
|
|
56
|
+
] }),
|
|
57
|
+
/* @__PURE__ */ jsxs(Button, { size: "sm", className: "bg-brand-rose hover:brightness-110 text-white", disabled: busy, onClick: () => respond(p.proposalId, "accept"), children: [
|
|
58
|
+
busy && activeId === p.proposalId ? /* @__PURE__ */ jsx(Loader2, { className: "h-3 w-3 animate-spin" }) : /* @__PURE__ */ jsx(CheckCircle2, { className: "h-3 w-3" }),
|
|
59
|
+
"Accept"
|
|
60
|
+
] })
|
|
61
|
+
] })
|
|
62
|
+
] }, p.proposalId)),
|
|
63
|
+
tx.phase === "error" && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-xs text-destructive", role: "alert", children: [
|
|
64
|
+
/* @__PURE__ */ jsx(AlertCircle, { className: "h-3.5 w-3.5" }),
|
|
65
|
+
tx.error,
|
|
66
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "underline", onClick: tx.reset, children: "Dismiss" })
|
|
67
|
+
] })
|
|
68
|
+
] });
|
|
69
|
+
}
|
|
70
|
+
function SponsorshipCreate({ aside }) {
|
|
71
|
+
const app = useMedialaneApp();
|
|
72
|
+
const walletAddress = app.walletAddress;
|
|
73
|
+
const resolveImage = useImageUrl();
|
|
74
|
+
const tx = useTransaction();
|
|
75
|
+
const [formError, setFormError] = useState(null);
|
|
76
|
+
const [mode, setMode] = useState("propose");
|
|
77
|
+
const [selectedAsset, setSelectedAsset] = useState(null);
|
|
78
|
+
const [proposeAsset, setProposeAsset] = useState(null);
|
|
79
|
+
const [terms, setTerms] = useState({ ...EMPTY_SPONSORSHIP_TERMS, paymentTokenSymbol: "USDC" });
|
|
80
|
+
const busy = tx.phase !== "idle";
|
|
81
|
+
const { tokens: ownedTokens, isLoading: assetsLoading } = useTokensByOwner(walletAddress ?? null, 1, 100);
|
|
82
|
+
const ownedAssets = ownedTokens.map((t) => ({
|
|
83
|
+
contractAddress: t.contractAddress,
|
|
84
|
+
tokenId: t.tokenId,
|
|
85
|
+
name: t.metadata?.name ?? `Token #${t.tokenId}`,
|
|
86
|
+
image: resolveImage(t.metadata?.image)
|
|
87
|
+
}));
|
|
88
|
+
const searchAssets = async (query) => {
|
|
89
|
+
const res = await app.getClient().api.search(query, 16);
|
|
90
|
+
return res.data.tokens.map((t) => ({
|
|
91
|
+
contractAddress: t.contractAddress,
|
|
92
|
+
tokenId: t.tokenId,
|
|
93
|
+
name: t.name ?? `Token #${t.tokenId}`,
|
|
94
|
+
image: resolveImage(t.image)
|
|
95
|
+
}));
|
|
96
|
+
};
|
|
97
|
+
const chosen = mode === "offer" ? selectedAsset : proposeAsset;
|
|
98
|
+
const onSubmit = () => {
|
|
99
|
+
setFormError(null);
|
|
100
|
+
if (!walletAddress) return setFormError("Your account isn't ready yet. Refresh the page and try again.");
|
|
101
|
+
if (!chosen) return setFormError(mode === "offer" ? "Choose which asset you're offering." : "Search for the asset you want to sponsor, then pick it.");
|
|
102
|
+
if (!terms.amount || Number(terms.amount) <= 0) return setFormError("Add an amount before continuing.");
|
|
103
|
+
const token = getTokenBySymbol(terms.paymentTokenSymbol);
|
|
104
|
+
if (!token) return setFormError("Pick a currency.");
|
|
105
|
+
const durationDays = toDurationDays(terms);
|
|
106
|
+
if (!durationDays) return setFormError("Choose how long the license should last.");
|
|
107
|
+
void tx.run(async (signer) => {
|
|
108
|
+
await app.ensureSignedIn?.();
|
|
109
|
+
const api = app.getClient().api;
|
|
110
|
+
const licenseTermsUri = await uploadJsonToIpfs(api, toLicenseMetadata(terms));
|
|
111
|
+
const amount = BigInt(Math.round(Number(terms.amount) * 10 ** token.decimals)).toString();
|
|
112
|
+
const duration = durationDays * 86400;
|
|
113
|
+
const royaltyBps = Math.round(Number(terms.royaltyPercent || "0") * 100);
|
|
114
|
+
await runIntentCalls(
|
|
115
|
+
signer,
|
|
116
|
+
() => mode === "offer" ? api.intents.create("sponsorship-offer", {
|
|
117
|
+
author: walletAddress,
|
|
118
|
+
nftContract: chosen.contractAddress,
|
|
119
|
+
tokenId: chosen.tokenId,
|
|
120
|
+
minAmount: amount,
|
|
121
|
+
duration,
|
|
122
|
+
paymentToken: token.address,
|
|
123
|
+
licenseTermsUri,
|
|
124
|
+
transferable: terms.transferable,
|
|
125
|
+
royaltyBps
|
|
126
|
+
}) : api.intents.create("sponsorship-proposal", {
|
|
127
|
+
proposer: walletAddress,
|
|
128
|
+
nftContract: chosen.contractAddress,
|
|
129
|
+
tokenId: chosen.tokenId,
|
|
130
|
+
amount,
|
|
131
|
+
duration,
|
|
132
|
+
paymentToken: token.address,
|
|
133
|
+
licenseTermsUri,
|
|
134
|
+
transferable: terms.transferable,
|
|
135
|
+
royaltyBps
|
|
136
|
+
})
|
|
137
|
+
);
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
const handleAgain = () => {
|
|
141
|
+
tx.reset();
|
|
142
|
+
setSelectedAsset(null);
|
|
143
|
+
setProposeAsset(null);
|
|
144
|
+
setTerms({ ...EMPTY_SPONSORSHIP_TERMS, paymentTokenSymbol: "USDC" });
|
|
145
|
+
};
|
|
146
|
+
return /* @__PURE__ */ jsxs(
|
|
147
|
+
WalletRequired,
|
|
148
|
+
{
|
|
149
|
+
icon: Handshake,
|
|
150
|
+
iconClassName: "text-brand-rose",
|
|
151
|
+
title: "Secure your account to set up a sponsorship",
|
|
152
|
+
description: "Secure your account to publish onchain.",
|
|
153
|
+
children: [
|
|
154
|
+
/* @__PURE__ */ jsx(
|
|
155
|
+
ClaimRouteShell,
|
|
156
|
+
{
|
|
157
|
+
icon: /* @__PURE__ */ jsx(Handshake, { className: "h-4 w-4 text-white" }),
|
|
158
|
+
title: "Set up a sponsorship",
|
|
159
|
+
subtitle: "Found IP you'd like to back? Propose terms directly to its owner. Own something worth sponsoring? Post it and let sponsors bid.",
|
|
160
|
+
aside,
|
|
161
|
+
children: /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
|
|
162
|
+
/* @__PURE__ */ jsx("div", { className: "inline-flex rounded-full border border-border p-1 bg-card", children: ["offer", "propose"].map((m) => /* @__PURE__ */ jsx(
|
|
163
|
+
"button",
|
|
164
|
+
{
|
|
165
|
+
type: "button",
|
|
166
|
+
onClick: () => setMode(m),
|
|
167
|
+
className: mode === m ? "px-4 py-1.5 rounded-full text-sm font-semibold bg-gradient-to-r from-brand-purple to-brand-blue text-white" : "px-4 py-1.5 rounded-full text-sm font-semibold text-muted-foreground",
|
|
168
|
+
children: m === "offer" ? "Offer my asset" : "Propose to sponsor"
|
|
169
|
+
},
|
|
170
|
+
m
|
|
171
|
+
)) }),
|
|
172
|
+
mode === "offer" ? /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
173
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-semibold", children: "Pick an asset you own" }),
|
|
174
|
+
/* @__PURE__ */ jsx(
|
|
175
|
+
AssetPicker,
|
|
176
|
+
{
|
|
177
|
+
assets: ownedAssets,
|
|
178
|
+
isLoading: assetsLoading,
|
|
179
|
+
selected: selectedAsset,
|
|
180
|
+
onSelect: setSelectedAsset,
|
|
181
|
+
emptyStateHref: "/launchpad/single-editions",
|
|
182
|
+
emptyStateLabel: "Create one"
|
|
183
|
+
}
|
|
184
|
+
),
|
|
185
|
+
selectedAsset ? /* @__PURE__ */ jsx(PendingProposalsPanel, { nftContract: selectedAsset.contractAddress }) : null
|
|
186
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
187
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-semibold", children: "Which asset do you want to sponsor?" }),
|
|
188
|
+
/* @__PURE__ */ jsx(AssetSearchPicker, { search: searchAssets, selected: proposeAsset, onSelect: setProposeAsset, placeholder: "Search by asset name or creator" })
|
|
189
|
+
] }),
|
|
190
|
+
/* @__PURE__ */ jsx("div", { className: "pt-2 border-t border-border/30", children: /* @__PURE__ */ jsx(
|
|
191
|
+
LicenseTermsBuilder,
|
|
192
|
+
{
|
|
193
|
+
value: terms,
|
|
194
|
+
onChange: setTerms,
|
|
195
|
+
tokenOptions: TOKEN_SYMBOLS,
|
|
196
|
+
amountLabel: mode === "offer" ? "Minimum accepted bid" : "Amount you'll pay",
|
|
197
|
+
disabled: busy
|
|
198
|
+
}
|
|
199
|
+
) }),
|
|
200
|
+
formError && /* @__PURE__ */ jsx("p", { role: "alert", className: "text-sm text-destructive", children: formError }),
|
|
201
|
+
/* @__PURE__ */ jsx("div", { className: "btn-border-animated p-[1px] rounded-2xl", children: /* @__PURE__ */ jsxs(
|
|
202
|
+
"button",
|
|
203
|
+
{
|
|
204
|
+
type: "button",
|
|
205
|
+
disabled: busy,
|
|
206
|
+
onClick: onSubmit,
|
|
207
|
+
className: "w-full h-12 rounded-[15px] flex items-center justify-center gap-2 text-base font-semibold text-white bg-transparent transition-all hover:brightness-110 active:scale-[0.98] disabled:opacity-50",
|
|
208
|
+
children: [
|
|
209
|
+
/* @__PURE__ */ jsx(Handshake, { className: "h-4 w-4" }),
|
|
210
|
+
mode === "offer" ? "Create Offer" : "Send proposal"
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
) })
|
|
214
|
+
] })
|
|
215
|
+
}
|
|
216
|
+
),
|
|
217
|
+
/* @__PURE__ */ jsx(
|
|
218
|
+
TransactionDialog,
|
|
219
|
+
{
|
|
220
|
+
tx,
|
|
221
|
+
title: mode === "offer" ? "Create sponsorship offer" : "Send proposal",
|
|
222
|
+
workingLabel: mode === "offer" ? "Creating your sponsorship offer\u2026" : "Sending your proposal\u2026",
|
|
223
|
+
firstStepLabel: "Upload license terms",
|
|
224
|
+
children: /* @__PURE__ */ jsx(
|
|
225
|
+
CreationSuccess,
|
|
226
|
+
{
|
|
227
|
+
name: chosen?.name ?? "Your sponsorship",
|
|
228
|
+
image: chosen?.image ?? null,
|
|
229
|
+
caption: mode === "offer" ? "Your offer is live" : "Your proposal is sent",
|
|
230
|
+
primary: { href: "/launchpad/sponsorship", label: "Back to Sponsorship launchpad" },
|
|
231
|
+
onAgain: handleAgain,
|
|
232
|
+
againLabel: "Create another",
|
|
233
|
+
children: mode === "offer" && /* @__PURE__ */ jsx(RewardEarned, { actionType: "create_sponsorship_offer" })
|
|
234
|
+
}
|
|
235
|
+
)
|
|
236
|
+
}
|
|
237
|
+
)
|
|
238
|
+
]
|
|
239
|
+
}
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
export {
|
|
243
|
+
SponsorshipCreate
|
|
244
|
+
};
|
|
245
|
+
//# sourceMappingURL=sponsorship-create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/launchpad/sponsorship-create.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState, type ReactNode } from \"react\";\nimport { AlertCircle, CheckCircle2, Handshake, Loader2, X } from \"lucide-react\";\nimport { SUPPORTED_TOKENS, getTokenBySymbol } from \"@medialane/sdk\";\nimport { Button } from \"../button.js\";\nimport { AssetPicker, type OwnedAsset } from \"../asset-picker.js\";\nimport { AssetSearchPicker } from \"../asset-search-picker.js\";\nimport { LicenseTermsBuilder, EMPTY_SPONSORSHIP_TERMS, toDurationDays, toLicenseMetadata, type SponsorshipTerms } from \"../license-terms-builder.js\";\nimport { ClaimRouteShell } from \"../claim-route-shell.js\";\nimport { CreationSuccess } from \"../creation-success.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 { runIntentCalls } from \"../../utils/run-intent-calls.js\";\nimport { uploadJsonToIpfs } from \"../../utils/ipfs-upload.js\";\nimport { useImageUrl } from \"../../utils/use-image-url.js\";\nimport { useTokensByOwner } from \"../../utils/use-tokens.js\";\nimport { usePendingProposalsForAsset } from \"../../utils/use-sponsorship.js\";\nimport { useTransaction } from \"../../utils/use-transaction.js\";\nimport { shortenAddress } from \"../../utils/address.js\";\n\ntype Mode = \"offer\" | \"propose\";\n\nconst TOKEN_SYMBOLS = SUPPORTED_TOKENS.filter((t) => t.listable).map((t) => t.symbol);\n\nfunction PendingProposalsPanel({ nftContract }: { nftContract: string }) {\n const app = useMedialaneApp();\n const walletAddress = app.walletAddress;\n const { proposals, isLoading, mutate } = usePendingProposalsForAsset(nftContract);\n const tx = useTransaction();\n const [activeId, setActiveId] = useState<string | null>(null);\n const busy = tx.phase === \"preparing\" || tx.phase === \"submitting\" || tx.phase === \"confirming\";\n\n const respond = (proposalId: string, decision: \"accept\" | \"reject\") => {\n if (!walletAddress) return;\n setActiveId(proposalId);\n void tx\n .run(async (signer) => {\n const api = app.getClient().api;\n await runIntentCalls(signer, () =>\n decision === \"accept\"\n ? api.intents.create(\"sponsorship-proposal-accept\", { owner: walletAddress, proposalId })\n : api.intents.create(\"sponsorship-proposal-reject\", { owner: walletAddress, proposalId }),\n );\n await mutate();\n })\n .finally(() => setActiveId(null));\n };\n\n if (isLoading || proposals.length === 0) return null;\n\n return (\n <div className=\"rounded-xl border border-border bg-card p-4 space-y-3\">\n <p className=\"text-sm font-semibold\">Pending proposals</p>\n {proposals.map((p) => (\n <div key={p.proposalId} className=\"flex items-center justify-between gap-3 text-sm\">\n <span className=\"truncate text-muted-foreground\">{shortenAddress(p.proposer)} — {p.amount}</span>\n <div className=\"flex gap-2 shrink-0\">\n <Button size=\"sm\" variant=\"outline\" disabled={busy} onClick={() => respond(p.proposalId, \"reject\")}>\n {busy && activeId === p.proposalId ? <Loader2 className=\"h-3 w-3 animate-spin\" /> : <X className=\"h-3 w-3\" />}\n Decline\n </Button>\n <Button size=\"sm\" className=\"bg-brand-rose hover:brightness-110 text-white\" disabled={busy} onClick={() => respond(p.proposalId, \"accept\")}>\n {busy && activeId === p.proposalId ? <Loader2 className=\"h-3 w-3 animate-spin\" /> : <CheckCircle2 className=\"h-3 w-3\" />}\n Accept\n </Button>\n </div>\n </div>\n ))}\n {tx.phase === \"error\" && (\n <div className=\"flex items-center gap-2 text-xs text-destructive\" role=\"alert\">\n <AlertCircle className=\"h-3.5 w-3.5\" />\n {tx.error}\n <button type=\"button\" className=\"underline\" onClick={tx.reset}>Dismiss</button>\n </div>\n )}\n </div>\n );\n}\n\nexport function SponsorshipCreate({ aside }: { aside?: ReactNode }) {\n const app = useMedialaneApp();\n const walletAddress = app.walletAddress;\n const resolveImage = useImageUrl();\n const tx = useTransaction();\n const [formError, setFormError] = useState<string | null>(null);\n const [mode, setMode] = useState<Mode>(\"propose\");\n const [selectedAsset, setSelectedAsset] = useState<OwnedAsset | null>(null);\n const [proposeAsset, setProposeAsset] = useState<OwnedAsset | null>(null);\n const [terms, setTerms] = useState<SponsorshipTerms>({ ...EMPTY_SPONSORSHIP_TERMS, paymentTokenSymbol: \"USDC\" });\n const busy = tx.phase !== \"idle\";\n\n const { tokens: ownedTokens, isLoading: assetsLoading } = useTokensByOwner(walletAddress ?? null, 1, 100);\n const ownedAssets: OwnedAsset[] = ownedTokens.map((t) => ({\n contractAddress: t.contractAddress,\n tokenId: t.tokenId,\n name: t.metadata?.name ?? `Token #${t.tokenId}`,\n image: resolveImage(t.metadata?.image),\n }));\n\n const searchAssets = async (query: string): Promise<OwnedAsset[]> => {\n const res = await app.getClient().api.search(query, 16);\n return res.data.tokens.map((t) => ({\n contractAddress: t.contractAddress,\n tokenId: t.tokenId,\n name: t.name ?? `Token #${t.tokenId}`,\n image: resolveImage(t.image),\n }));\n };\n\n const chosen = mode === \"offer\" ? selectedAsset : proposeAsset;\n\n const onSubmit = () => {\n setFormError(null);\n if (!walletAddress) return setFormError(\"Your account isn't ready yet. Refresh the page and try again.\");\n if (!chosen) return setFormError(mode === \"offer\" ? \"Choose which asset you're offering.\" : \"Search for the asset you want to sponsor, then pick it.\");\n if (!terms.amount || Number(terms.amount) <= 0) return setFormError(\"Add an amount before continuing.\");\n const token = getTokenBySymbol(terms.paymentTokenSymbol);\n if (!token) return setFormError(\"Pick a currency.\");\n const durationDays = toDurationDays(terms);\n if (!durationDays) return setFormError(\"Choose how long the license should last.\");\n\n void tx.run(async (signer) => {\n await app.ensureSignedIn?.();\n const api = app.getClient().api;\n const licenseTermsUri = await uploadJsonToIpfs(api, toLicenseMetadata(terms));\n const amount = BigInt(Math.round(Number(terms.amount) * 10 ** token.decimals)).toString();\n const duration = durationDays * 86400;\n const royaltyBps = Math.round(Number(terms.royaltyPercent || \"0\") * 100);\n await runIntentCalls(signer, () =>\n mode === \"offer\"\n ? api.intents.create(\"sponsorship-offer\", {\n author: walletAddress, nftContract: chosen.contractAddress, tokenId: chosen.tokenId, minAmount: amount,\n duration, paymentToken: token.address, licenseTermsUri, transferable: terms.transferable, royaltyBps,\n })\n : api.intents.create(\"sponsorship-proposal\", {\n proposer: walletAddress, nftContract: chosen.contractAddress, tokenId: chosen.tokenId, amount,\n duration, paymentToken: token.address, licenseTermsUri, transferable: terms.transferable, royaltyBps,\n }),\n );\n });\n };\n\n const handleAgain = () => {\n tx.reset();\n setSelectedAsset(null);\n setProposeAsset(null);\n setTerms({ ...EMPTY_SPONSORSHIP_TERMS, paymentTokenSymbol: \"USDC\" });\n };\n\n return (\n <WalletRequired\n icon={Handshake}\n iconClassName=\"text-brand-rose\"\n title=\"Secure your account to set up a sponsorship\"\n description=\"Secure your account to publish onchain.\"\n >\n <ClaimRouteShell\n icon={<Handshake className=\"h-4 w-4 text-white\" />}\n title=\"Set up a sponsorship\"\n subtitle=\"Found IP you'd like to back? Propose terms directly to its owner. Own something worth sponsoring? Post it and let sponsors bid.\"\n aside={aside}\n >\n <div className=\"space-y-6\">\n <div className=\"inline-flex rounded-full border border-border p-1 bg-card\">\n {([\"offer\", \"propose\"] as const).map((m) => (\n <button\n key={m}\n type=\"button\"\n onClick={() => setMode(m)}\n className={\n mode === m\n ? \"px-4 py-1.5 rounded-full text-sm font-semibold bg-gradient-to-r from-brand-purple to-brand-blue text-white\"\n : \"px-4 py-1.5 rounded-full text-sm font-semibold text-muted-foreground\"\n }\n >\n {m === \"offer\" ? \"Offer my asset\" : \"Propose to sponsor\"}\n </button>\n ))}\n </div>\n\n {mode === \"offer\" ? (\n <div className=\"space-y-2\">\n <p className=\"text-sm font-semibold\">Pick an asset you own</p>\n <AssetPicker\n assets={ownedAssets}\n isLoading={assetsLoading}\n selected={selectedAsset}\n onSelect={setSelectedAsset}\n emptyStateHref=\"/launchpad/single-editions\"\n emptyStateLabel=\"Create one\"\n />\n {selectedAsset ? <PendingProposalsPanel nftContract={selectedAsset.contractAddress} /> : null}\n </div>\n ) : (\n <div className=\"space-y-2\">\n <p className=\"text-sm font-semibold\">Which asset do you want to sponsor?</p>\n <AssetSearchPicker search={searchAssets} selected={proposeAsset} onSelect={setProposeAsset} placeholder=\"Search by asset name or creator\" />\n </div>\n )}\n\n <div className=\"pt-2 border-t border-border/30\">\n <LicenseTermsBuilder\n value={terms}\n onChange={setTerms}\n tokenOptions={TOKEN_SYMBOLS}\n amountLabel={mode === \"offer\" ? \"Minimum accepted bid\" : \"Amount you'll pay\"}\n disabled={busy}\n />\n </div>\n\n {formError && <p role=\"alert\" className=\"text-sm text-destructive\">{formError}</p>}\n\n <div className=\"btn-border-animated p-[1px] rounded-2xl\">\n <button\n type=\"button\"\n disabled={busy}\n onClick={onSubmit}\n className=\"w-full h-12 rounded-[15px] flex items-center justify-center gap-2 text-base font-semibold text-white bg-transparent transition-all hover:brightness-110 active:scale-[0.98] disabled:opacity-50\"\n >\n <Handshake className=\"h-4 w-4\" />\n {mode === \"offer\" ? \"Create Offer\" : \"Send proposal\"}\n </button>\n </div>\n </div>\n </ClaimRouteShell>\n\n <TransactionDialog\n tx={tx}\n title={mode === \"offer\" ? \"Create sponsorship offer\" : \"Send proposal\"}\n workingLabel={mode === \"offer\" ? \"Creating your sponsorship offer…\" : \"Sending your proposal…\"}\n firstStepLabel=\"Upload license terms\"\n >\n <CreationSuccess\n name={chosen?.name ?? \"Your sponsorship\"}\n image={chosen?.image ?? null}\n caption={mode === \"offer\" ? \"Your offer is live\" : \"Your proposal is sent\"}\n primary={{ href: \"/launchpad/sponsorship\", label: \"Back to Sponsorship launchpad\" }}\n onAgain={handleAgain}\n againLabel=\"Create another\"\n >\n {mode === \"offer\" && <RewardEarned actionType=\"create_sponsorship_offer\" />}\n </CreationSuccess>\n </TransactionDialog>\n </WalletRequired>\n );\n}\n"],"mappings":";AAuDM,cAGI,YAHJ;AArDN,SAAS,gBAAgC;AACzC,SAAS,aAAa,cAAc,WAAW,SAA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