From 349d4900bb9f13cfa14b7e44c387628b2fee781f Mon Sep 17 00:00:00 2001 From: ahmednahima0-beep Date: Sat, 9 May 2026 13:42:35 +0700 Subject: [PATCH] deleting unnecessary files --- app/api/agentkit/run/route.ts | 23 ------- app/api/in_process/createCollection.ts | 89 -------------------------- components/shared/StartButton.tsx | 52 --------------- lib/email/generateTxtFileEmail.ts | 53 --------------- lib/generateAndProcessImage.ts | 77 ---------------------- lib/txtGeneration.ts | 76 ---------------------- 6 files changed, 370 deletions(-) delete mode 100644 app/api/agentkit/run/route.ts delete mode 100644 app/api/in_process/createCollection.ts delete mode 100644 components/shared/StartButton.tsx delete mode 100644 lib/email/generateTxtFileEmail.ts delete mode 100644 lib/generateAndProcessImage.ts delete mode 100644 lib/txtGeneration.ts diff --git a/app/api/agentkit/run/route.ts b/app/api/agentkit/run/route.ts deleted file mode 100644 index d32e3cab1..000000000 --- a/app/api/agentkit/run/route.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { NextResponse } from "next/server"; - -export async function GET() { - try { - const response = await fetch( - "http://143.198.164.177:3000/api/agentkit/run", - { - headers: { - "Content-Type": "application/json", - }, - }, - ); - const data = await response.json(); - return NextResponse.json(data); - } catch (error) { - console.error("Error:", error); - return NextResponse.json({ error: "Failed to fetch" }, { status: 500 }); - } -} - -export const dynamic = "force-dynamic"; -export const fetchCache = "force-no-store"; -export const revalidate = 0; diff --git a/app/api/in_process/createCollection.ts b/app/api/in_process/createCollection.ts deleted file mode 100644 index 8c76a7a50..000000000 --- a/app/api/in_process/createCollection.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { inProcessProtocolAbi } from "@/abi/inProcessProtocolAbi"; -import { getSetupNewTokenCall } from "@/app/lib/in_process/getSetupNewTokenCall"; -import { - IN_PROCESS_PROTOCOL_ADDRESS, - IS_PROD, - PAYMASTER_URL, -} from "@/lib/consts"; -import { CdpClient } from "@coinbase/cdp-sdk"; -import { encodeFunctionData } from "viem"; - -// Main function to create a collection -interface CreateCollectionParams { - collectionName: string; - uri: string; -} - -async function createCollection({ - collectionName, - uri, -}: CreateCollectionParams) { - // Initialize CDP client with your credentials - const cdp = new CdpClient({ - apiKeyId: process.env.CDP_API_KEY_ID, - apiKeySecret: process.env.CDP_API_KEY_SECRET, - walletSecret: process.env.CDP_WALLET_SECRET, - }); - - // Create a new account - const evmAccount = await cdp.evm.createAccount(); - - // Create a smart account (contract wallet) - const smartAccount = await cdp.evm.createSmartAccount({ - owner: evmAccount, - }); - - // Royalty configuration - const royaltyConfig = { - royaltyMintSchedule: 0, - royaltyBPS: 500, // 5% royalties (set to 1000 for 10%) - royaltyRecipient: smartAccount.address, - }; - - const setupActions = [getSetupNewTokenCall({ uri })]; - - // Encode the function call data - const createContractData = encodeFunctionData({ - abi: inProcessProtocolAbi, - functionName: "createContract", - args: [ - uri, - collectionName, - royaltyConfig, - smartAccount.address, // defaultAdmin - setupActions, - ], - }); - - // Send the transaction - const sendResult = await cdp.evm.sendUserOperation({ - smartAccount, - network: IS_PROD ? "base" : "base-sepolia", // supported networks: https://docs.cdp.coinbase.com/api/docs/networks#network-identifiers - paymasterUrl: PAYMASTER_URL, - calls: [ - { - to: IN_PROCESS_PROTOCOL_ADDRESS, // https://docs-in-process.vercel.app/protocol-deployments - data: createContractData, - }, - ], - }); - - // Wait for the transaction to be mined - await cdp.evm.waitForUserOperation({ - smartAccountAddress: smartAccount.address, - userOpHash: sendResult.userOpHash, - }); - - // Get the transaction details - const userOp = await cdp.evm.getUserOperation({ - smartAccount, - userOpHash: sendResult.userOpHash, - }); - - return { - smartAccount, - transactionHash: userOp.transactionHash, - }; -} - -export default createCollection; diff --git a/components/shared/StartButton.tsx b/components/shared/StartButton.tsx deleted file mode 100644 index 09fe01103..000000000 --- a/components/shared/StartButton.tsx +++ /dev/null @@ -1,52 +0,0 @@ -"use client"; - -import { Button } from "@/components/ui/button"; -import { usePrivy } from "@privy-io/react-auth"; -import { useState } from "react"; - -export function StartButton() { - const [isLoading, setIsLoading] = useState(false); - const [walletAddress, setWalletAddress] = useState(null); - const { login, authenticated } = usePrivy(); - - const handleClick = async () => { - if (!authenticated) { - login(); - return; - } - - try { - setIsLoading(true); - const response = await fetch("/api/agentkit/run"); - const data = await response.json(); - if (data.walletAddress) { - setWalletAddress(data.walletAddress); - } - } catch (error) { - console.error("Error:", error); - } finally { - setIsLoading(false); - } - }; - - return ( -
- - {walletAddress && ( -
-

- Your Agent's Wallet Address: -

-

{walletAddress}

-
- )} -
- ); -} diff --git a/lib/email/generateTxtFileEmail.ts b/lib/email/generateTxtFileEmail.ts deleted file mode 100644 index 6e2635e26..000000000 --- a/lib/email/generateTxtFileEmail.ts +++ /dev/null @@ -1,53 +0,0 @@ -import generateText from "@/lib/ai/generateText"; -import sendEmail from "@/lib/email/sendEmail"; -import { RECOUP_FROM_EMAIL } from "../consts"; -import { getFetchableUrl } from "../arweave/gateway"; - -/** - * Sends a Recoup Apify webhook email to a list of emails, summarizing the dataset and using a strong CTA. - * @param dataset - Array of dataset objects (from Apify) - * @param emails - Array of email addresses to send to - * @returns The result of sendEmail - */ -export default async function generateTxtFileEmail({ - rawTextFile, - arweaveFile, - emails, - conversationId, -}: { - rawTextFile: string; - arweaveFile: string; - emails: string[]; - conversationId: string; -}) { - if (!emails?.length) return null; - const ctaUrl = `https://chat.recoupable.com/chat/${conversationId}`; - const prompt = `You have a newly generated TXT file. Here is the data: - -Key Data -Raw Text File: ${rawTextFile} -Link to view the full TXT File: ${getFetchableUrl(arweaveFile)} -CTA URL: ${ctaUrl} -`; - - const { text } = await generateText({ - system: `you are a record label services manager for Recoup. - write beautiful html email. - subject: New TXT File Notification. you're notifying music managers about a new txt file they've generated using Recoup Chat (AI Agents). - include a button to view the txt file (onClick open the CTA URL). - do not mention arweave in your email. - call to action is to open the original conversation where the txt file was generated using Recoup Chat (AI Agents): ${ctaUrl} - You'll be passed a raw text file and a link to view the full TXT File. - your goal is to get the recipient to click a cta link to open the original conversation where the txt file was generated using Recoup Chat (AI Agents). - only include the email body html. - no headers or subject`, - prompt, - }); - - return await sendEmail({ - from: RECOUP_FROM_EMAIL, - to: emails, - subject: `Recoup - New TXT File Created`, - html: text, - }); -} diff --git a/lib/generateAndProcessImage.ts b/lib/generateAndProcessImage.ts deleted file mode 100644 index 026ca30ce..000000000 --- a/lib/generateAndProcessImage.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { Experimental_GenerateImageResult } from "ai"; -import Transaction from "arweave/node/lib/transaction"; -import { Address, Hash } from "viem"; -import { getClientApiBaseUrl } from "@/lib/api/getClientApiBaseUrl"; - -interface RecoupImageGenerateResponse extends Experimental_GenerateImageResult { - imageUrl: string; - arweaveResult: Transaction; - moment: { - contractAddress: Address; - tokenId: string; - hash: Hash; - chainId: number; - }; -} - -export interface GeneratedImageResponse { - imageUrl: string | null; -} - -interface FileInput { - url: string; - type: string; -} - -export async function generateAndProcessImage( - prompt: string, - accountId: string, - files?: FileInput[] -): Promise { - if (!prompt) { - throw new Error("Prompt is required"); - } - - if (!accountId) { - throw new Error("Account ID is required"); - } - - const apiUrl = new URL(`${getClientApiBaseUrl()}/api/image/generate`); - apiUrl.searchParams.set("prompt", prompt); - apiUrl.searchParams.set("account_id", accountId); - - // Format files parameter: files=url1:type1|url2:type2 - if (files && files.length > 0) { - const filesParam = files - .map((file) => `${file.url}:${file.type}`) - .join("|"); - apiUrl.searchParams.set("files", filesParam); - } - - const response = await fetch(apiUrl.toString(), { - method: "GET", - headers: { - "Content-Type": "application/json", - }, - }); - - if (!response.ok) { - const errorText = await response.text(); - let errorMessage = `HTTP error! status: ${response.status}`; - - try { - const errorData = JSON.parse(errorText); - errorMessage = errorData.message || errorData.error || errorMessage; - } catch { - errorMessage = errorText || errorMessage; - } - - throw new Error(errorMessage); - } - - const data: RecoupImageGenerateResponse = await response.json(); - - return { - imageUrl: data.imageUrl || null, - }; -} diff --git a/lib/txtGeneration.ts b/lib/txtGeneration.ts deleted file mode 100644 index 5d9e963c2..000000000 --- a/lib/txtGeneration.ts +++ /dev/null @@ -1,76 +0,0 @@ -import createCollection from "@/app/api/in_process/createCollection"; -import { uploadMetadataJson } from "./arweave/uploadMetadataJson"; -import uploadToArweave from "./arweave/uploadToArweave"; - -export interface GeneratedTxtResponse { - txt: { - base64Data: string; - mimeType: string; - }; - arweave?: string | null; - smartAccount: { - address: string; - [key: string]: unknown; - }; - transactionHash: string | null; -} - -export async function generateAndStoreTxtFile( - contents: string -): Promise { - if (!contents) { - throw new Error("Contents are required"); - } - - // Encode contents to base64 - const base64Data = Buffer.from(contents, "utf-8").toString("base64"); - const mimeType = "text/plain"; - - // Upload the TXT file to Arweave - let txtFile = null; - try { - txtFile = await uploadToArweave({ - base64Data, - mimeType, - }); - } catch (arweaveError) { - console.error("Error uploading TXT to Arweave:", arweaveError); - // Continue and return the TXT even if Arweave upload fails - } - - const image = "ar://EXwe2peizXKxjUMop6W-JPflC5sWyeQR1y0JiRDwUB0"; - - // Upload metadata JSON to Arweave - let metadataArweave = null; - try { - metadataArweave = await uploadMetadataJson({ - image, - animation_url: txtFile || undefined, - content: { - mime: mimeType, - uri: txtFile || "", - }, - description: contents, - name: contents, - }); - } catch (metadataError) { - console.error("Error uploading metadata to Arweave:", metadataError); - } - - // Create a collection on the blockchain using the metadata id - const result = await createCollection({ - collectionName: contents, - uri: metadataArweave || "", - }); - const transactionHash = result.transactionHash || null; - - return { - txt: { - base64Data, - mimeType, - }, - arweave: txtFile, - smartAccount: result.smartAccount, - transactionHash, - }; -}