feat: auto-generate manifest

This commit is contained in:
lucas-neynar
2025-03-13 12:39:59 -07:00
parent 51f8c92eb3
commit b168e34521
14 changed files with 289 additions and 29 deletions

View File

@@ -1,17 +1,24 @@
import { readFileSync } from 'fs';
import { join } from 'path';
export async function GET() {
const appUrl = process.env.NEXT_PUBLIC_URL;
let accountAssociation; // TODO: add type
try {
const manifestPath = join(process.cwd(), 'public/manifest.json');
const manifest = JSON.parse(readFileSync(manifestPath, 'utf-8'));
accountAssociation = manifest;
} catch (error) {
console.warn('Warning: manifest.json not found or invalid. Frame will not be associated with an account.');
accountAssociation = null;
}
const config = {
accountAssociation: {
header:
"eyJmaWQiOjM2MjEsInR5cGUiOiJjdXN0b2R5Iiwia2V5IjoiMHgyY2Q4NWEwOTMyNjFmNTkyNzA4MDRBNkVBNjk3Q2VBNENlQkVjYWZFIn0",
payload: "eyJkb21haW4iOiJmcmFtZXMtdjIudmVyY2VsLmFwcCJ9",
signature:
"MHhiNDIwMzQ1MGZkNzgzYTExZjRiOTllZTFlYjA3NmMwOTdjM2JkOTY1NGM2ODZjYjkyZTAyMzk2Y2Q0YjU2MWY1MjY5NjI5ZGQ5NTliYjU0YzEwOGI4OGVmNjdjMTVlZTdjZDc2YTRiMGU5NzkzNzA3YzkxYzFkOWFjNTg0YmQzNjFi",
},
...(accountAssociation && { accountAssociation }),
frame: {
version: "1",
name: "Frames v2 Demo",
name: process.env.NEXT_PUBLIC_FRAME_NAME || "Frames v2 Demo",
iconUrl: `${appUrl}/icon.png`,
homeUrl: appUrl,
imageUrl: `${appUrl}/frames/hello/opengraph-image`,