moltlaunch 2.0.0 → 2.0.2

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.
Files changed (108) hide show
  1. package/README.md +2 -2
  2. package/dist/index.js +18 -18
  3. package/dist/index.js.map +1 -1
  4. package/package.json +6 -2
  5. package/.claude/commands/deploy.md +0 -33
  6. package/.claude/hooks/regenerate-docs.sh +0 -12
  7. package/.claude/settings.json +0 -15
  8. package/.env.example +0 -2
  9. package/.github/workflows/deploy.yml +0 -37
  10. package/ROADMAP.md +0 -29
  11. package/contracts/MandateEscrowV4.sol +0 -281
  12. package/contracts/mocks/MockFlaunchBuyback.sol +0 -24
  13. package/hardhat.config.cjs +0 -29
  14. package/scripts/check-deploy-cost.ts +0 -15
  15. package/scripts/deploy-escrow-v4.ts +0 -81
  16. package/scripts/deploy-escrow.cjs +0 -22
  17. package/scripts/generate-docs.ts +0 -309
  18. package/shared/manifest.json +0 -87
  19. package/site/.vscode/extensions.json +0 -4
  20. package/site/.vscode/launch.json +0 -11
  21. package/site/README.md +0 -43
  22. package/site/astro.config.mjs +0 -21
  23. package/site/functions/agent/[[path]].ts +0 -9
  24. package/site/functions/task/[[path]].ts +0 -9
  25. package/site/index.html.bak +0 -1755
  26. package/site/package-lock.json +0 -6165
  27. package/site/package.json +0 -17
  28. package/site/public/_redirects +0 -1
  29. package/site/public/art/hero.webp +0 -0
  30. package/site/public/favicon.ico +0 -0
  31. package/site/public/favicon.svg +0 -4
  32. package/site/public/logo.png +0 -0
  33. package/site/public/skill.md +0 -276
  34. package/site/src/components/AgentGridCard.astro +0 -97
  35. package/site/src/components/AgentRow.astro +0 -75
  36. package/site/src/components/Footer.astro +0 -71
  37. package/site/src/components/GigCard.astro +0 -36
  38. package/site/src/components/Navbar.astro +0 -93
  39. package/site/src/components/ReviewCard.astro +0 -29
  40. package/site/src/components/SkillPill.astro +0 -19
  41. package/site/src/components/StatusBadge.astro +0 -27
  42. package/site/src/components/TaskEntry.astro +0 -98
  43. package/site/src/layouts/Layout.astro +0 -268
  44. package/site/src/lib/api.ts +0 -342
  45. package/site/src/pages/404.astro +0 -33
  46. package/site/src/pages/admin.astro +0 -445
  47. package/site/src/pages/agent/[...id].astro +0 -678
  48. package/site/src/pages/agents/index.astro +0 -235
  49. package/site/src/pages/dashboard.astro +0 -244
  50. package/site/src/pages/docs.astro +0 -191
  51. package/site/src/pages/how.astro +0 -156
  52. package/site/src/pages/index.astro +0 -226
  53. package/site/src/pages/leaderboard.astro +0 -155
  54. package/site/src/pages/task/[...id].astro +0 -1467
  55. package/site/src/styles/global.css +0 -159
  56. package/site/tailwind.config.mjs +0 -94
  57. package/site/tsconfig.json +0 -5
  58. package/site/wrangler.toml +0 -5
  59. package/src/commands/accept.ts +0 -135
  60. package/src/commands/agents.ts +0 -190
  61. package/src/commands/approve.ts +0 -127
  62. package/src/commands/claim.ts +0 -130
  63. package/src/commands/decline.ts +0 -55
  64. package/src/commands/dispute.ts +0 -92
  65. package/src/commands/earnings.ts +0 -86
  66. package/src/commands/feedback.ts +0 -147
  67. package/src/commands/gig.ts +0 -141
  68. package/src/commands/hire.ts +0 -96
  69. package/src/commands/inbox.ts +0 -135
  70. package/src/commands/message.ts +0 -97
  71. package/src/commands/profile.ts +0 -62
  72. package/src/commands/quote.ts +0 -80
  73. package/src/commands/refund.ts +0 -82
  74. package/src/commands/register.ts +0 -250
  75. package/src/commands/resolve.ts +0 -104
  76. package/src/commands/reviews.ts +0 -78
  77. package/src/commands/revise.ts +0 -65
  78. package/src/commands/submit.ts +0 -123
  79. package/src/commands/tasks.ts +0 -224
  80. package/src/commands/view.ts +0 -122
  81. package/src/commands/wallet.ts +0 -42
  82. package/src/index.ts +0 -285
  83. package/src/lib/agent0.ts +0 -158
  84. package/src/lib/auth.ts +0 -25
  85. package/src/lib/constants.ts +0 -55
  86. package/src/lib/escrow.ts +0 -374
  87. package/src/lib/files.ts +0 -87
  88. package/src/lib/flaunch.ts +0 -277
  89. package/src/lib/mandate.ts +0 -623
  90. package/src/lib/tasks.ts +0 -466
  91. package/src/lib/types.ts +0 -112
  92. package/src/lib/wallet.ts +0 -119
  93. package/src/lib/x402.ts +0 -86
  94. package/test/MandateEscrowV4.test.cjs +0 -568
  95. package/tsconfig.json +0 -19
  96. package/tsup.config.ts +0 -15
  97. package/worker/package-lock.json +0 -1812
  98. package/worker/package.json +0 -18
  99. package/worker/src/agents.ts +0 -755
  100. package/worker/src/auth.ts +0 -126
  101. package/worker/src/files.ts +0 -40
  102. package/worker/src/index.ts +0 -963
  103. package/worker/src/profiles.ts +0 -85
  104. package/worker/src/ratelimit.ts +0 -45
  105. package/worker/src/tasks.ts +0 -498
  106. package/worker/src/types.ts +0 -95
  107. package/worker/tsconfig.json +0 -15
  108. package/worker/wrangler.toml +0 -19
@@ -1,277 +0,0 @@
1
- // Flaunch API wrapper for gasless token launches
2
- // Tokens are launched via Flaunch Web2 API (gasless) with MANDATE as revenue manager
3
-
4
- import { readFile, stat } from "node:fs/promises";
5
- import {
6
- APIS,
7
- CHAIN,
8
- REVENUE_MANAGER_ADDRESS,
9
- POLL_INTERVAL_MS,
10
- POLL_TIMEOUT_MS,
11
- MAX_IMAGE_SIZE_BYTES,
12
- } from "./constants.js";
13
-
14
- // Types
15
- interface FlaunchUploadResponse {
16
- success: boolean;
17
- ipfsHash: string;
18
- tokenURI: string;
19
- }
20
-
21
- interface FlaunchLaunchResponse {
22
- success: boolean;
23
- message: string;
24
- jobId: string;
25
- queueStatus: {
26
- position: number;
27
- waitingJobs: number;
28
- activeJobs: number;
29
- estimatedWaitSeconds: number;
30
- };
31
- }
32
-
33
- interface FlaunchStatusResponse {
34
- success: boolean;
35
- state: "waiting" | "active" | "completed" | "failed";
36
- queuePosition: number;
37
- estimatedWaitTime: number;
38
- transactionHash: string | null;
39
- error: string | null;
40
- collectionToken: {
41
- address: string;
42
- imageIpfs: string;
43
- name: string;
44
- symbol: string;
45
- tokenURI: string;
46
- creator: string;
47
- } | null;
48
- }
49
-
50
- export interface LaunchResult {
51
- tokenAddress: string;
52
- transactionHash: string;
53
- flaunchUrl: string;
54
- }
55
-
56
- function sleep(ms: number): Promise<void> {
57
- return new Promise((resolve) => setTimeout(resolve, ms));
58
- }
59
-
60
- async function fetchWithRetry(
61
- url: string,
62
- options: RequestInit,
63
- retries = 3,
64
- ): Promise<Response> {
65
- for (let attempt = 0; attempt < retries; attempt++) {
66
- const response = await fetch(url, options);
67
-
68
- if (response.status === 429) {
69
- const retryAfter = response.headers.get("retry-after");
70
- const waitMs = retryAfter ? parseInt(retryAfter, 10) * 1000 : 2000 * (attempt + 1);
71
- await sleep(waitMs);
72
- continue;
73
- }
74
-
75
- return response;
76
- }
77
-
78
- throw new Error("Max retries exceeded (429 rate limit)");
79
- }
80
-
81
- /**
82
- * Upload image to IPFS via Flaunch Web2 API.
83
- */
84
- export async function uploadImage(imagePath: string): Promise<string> {
85
- const fileStat = await stat(imagePath);
86
- if (fileStat.size > MAX_IMAGE_SIZE_BYTES) {
87
- throw new Error(`Image exceeds 5MB limit (${(fileStat.size / 1024 / 1024).toFixed(1)}MB)`);
88
- }
89
-
90
- const imageBuffer = await readFile(imagePath);
91
- const base64 = imageBuffer.toString("base64");
92
-
93
- const ext = imagePath.split(".").pop()?.toLowerCase();
94
- const mimeMap: Record<string, string> = {
95
- png: "image/png",
96
- jpg: "image/jpeg",
97
- jpeg: "image/jpeg",
98
- gif: "image/gif",
99
- webp: "image/webp",
100
- svg: "image/svg+xml",
101
- };
102
- const mime = mimeMap[ext ?? ""] ?? "image/png";
103
-
104
- const dataUrl = `data:${mime};base64,${base64}`;
105
-
106
- const response = await fetchWithRetry(`${APIS.FLAUNCH}/api/v1/upload-image`, {
107
- method: "POST",
108
- headers: { "Content-Type": "application/json" },
109
- body: JSON.stringify({ base64Image: dataUrl }),
110
- });
111
-
112
- if (!response.ok) {
113
- const text = await response.text();
114
- throw new Error(`Image upload failed: ${response.status} - ${text}`);
115
- }
116
-
117
- const data = (await response.json()) as FlaunchUploadResponse;
118
- return data.ipfsHash;
119
- }
120
-
121
- /**
122
- * Launch a token via Flaunch Web2 API.
123
- * This is gasless - Flaunch handles the on-chain transaction server-side.
124
- * MANDATE is set as revenue manager to capture 10% of trading fees.
125
- */
126
- export async function launchToken(params: {
127
- name: string;
128
- symbol: string;
129
- description: string;
130
- imageIpfs: string;
131
- creatorAddress: string;
132
- websiteUrl?: string;
133
- }): Promise<string> {
134
- const body: Record<string, string | number | undefined> = {
135
- name: params.name,
136
- symbol: params.symbol,
137
- description: params.description,
138
- imageIpfs: params.imageIpfs,
139
- creatorAddress: params.creatorAddress,
140
- revenueManagerAddress: REVENUE_MANAGER_ADDRESS,
141
- websiteUrl: params.websiteUrl,
142
- flaunchAt: 0, // immediate launch
143
- };
144
-
145
- // Strip undefined values
146
- for (const key of Object.keys(body)) {
147
- if (body[key] === undefined) delete body[key];
148
- }
149
-
150
- const response = await fetchWithRetry(
151
- `${APIS.FLAUNCH}/api/v1/${CHAIN.network}/launch-memecoin`,
152
- {
153
- method: "POST",
154
- headers: { "Content-Type": "application/json" },
155
- body: JSON.stringify(body),
156
- },
157
- );
158
-
159
- if (!response.ok) {
160
- const text = await response.text();
161
- throw new Error(`Launch failed: ${response.status} - ${text}`);
162
- }
163
-
164
- const data = (await response.json()) as FlaunchLaunchResponse;
165
- return data.jobId;
166
- }
167
-
168
- /**
169
- * Poll launch status until completed or failed.
170
- */
171
- export async function pollLaunchStatus(
172
- jobId: string,
173
- onPoll?: (state: string, position: number) => void,
174
- ): Promise<FlaunchStatusResponse> {
175
- const startTime = Date.now();
176
- let consecutiveErrors = 0;
177
-
178
- while (Date.now() - startTime < POLL_TIMEOUT_MS) {
179
- let response: Response;
180
- try {
181
- response = await fetch(`${APIS.FLAUNCH}/api/v1/launch-status/${jobId}`);
182
- } catch {
183
- consecutiveErrors++;
184
- if (consecutiveErrors >= 5) {
185
- throw new Error("Lost connection to Flaunch API during deployment");
186
- }
187
- await sleep(POLL_INTERVAL_MS);
188
- continue;
189
- }
190
-
191
- if (response.status === 429 || response.status >= 500) {
192
- consecutiveErrors++;
193
- if (consecutiveErrors >= 5) {
194
- throw new Error(`Status check failed after retries: ${response.status}`);
195
- }
196
- await sleep(POLL_INTERVAL_MS * (consecutiveErrors + 1));
197
- continue;
198
- }
199
-
200
- if (!response.ok) {
201
- const text = await response.text();
202
- throw new Error(`Status check failed: ${response.status} - ${text}`);
203
- }
204
-
205
- consecutiveErrors = 0;
206
- const data = (await response.json()) as FlaunchStatusResponse;
207
- onPoll?.(data.state, data.queuePosition);
208
-
209
- if (data.state === "completed") return data;
210
- if (data.state === "failed") {
211
- throw new Error(data.error ?? "Launch failed with no error message");
212
- }
213
-
214
- await sleep(POLL_INTERVAL_MS);
215
- }
216
-
217
- throw new Error("Launch timed out after 2 minutes");
218
- }
219
-
220
- /**
221
- * Full flow: upload image (if provided), launch token, poll until complete.
222
- * Returns token address and transaction hash.
223
- */
224
- export async function launchFlaunchToken(params: {
225
- name: string;
226
- symbol: string;
227
- description: string;
228
- imagePath?: string;
229
- creatorAddress: string;
230
- websiteUrl?: string;
231
- onProgress?: (message: string) => void;
232
- }): Promise<LaunchResult> {
233
- const { onProgress } = params;
234
-
235
- // Step 1: Upload image if provided
236
- let imageIpfs: string;
237
- if (params.imagePath) {
238
- onProgress?.("Uploading image to IPFS...");
239
- imageIpfs = await uploadImage(params.imagePath);
240
- onProgress?.(`Image uploaded: ${imageIpfs.slice(0, 16)}...`);
241
- } else {
242
- throw new Error("Image is required for token launch. Use --image <path>");
243
- }
244
-
245
- // Step 2: Submit launch
246
- onProgress?.("Submitting token launch...");
247
- const jobId = await launchToken({
248
- name: params.name,
249
- symbol: params.symbol,
250
- description: params.description,
251
- imageIpfs,
252
- creatorAddress: params.creatorAddress,
253
- websiteUrl: params.websiteUrl,
254
- });
255
- onProgress?.(`Launch queued (job ${jobId})`);
256
-
257
- // Step 3: Poll for completion
258
- onProgress?.("Deploying on-chain...");
259
- const result = await pollLaunchStatus(jobId, (state, position) => {
260
- if (position > 0) {
261
- onProgress?.(`Queue position: ${position}`);
262
- }
263
- });
264
-
265
- if (!result.collectionToken?.address || !result.transactionHash) {
266
- throw new Error("Launch completed but missing token address or transaction hash");
267
- }
268
-
269
- const tokenAddress = result.collectionToken.address;
270
- const flaunchUrl = `${CHAIN.flaunchUrl}/coin/${tokenAddress}`;
271
-
272
- return {
273
- tokenAddress,
274
- transactionHash: result.transactionHash,
275
- flaunchUrl,
276
- };
277
- }