fix: build script bug

This commit is contained in:
veganbeef 2025-06-13 18:19:19 -07:00
parent 8966dcee30
commit cfe51f067c
No known key found for this signature in database
3 changed files with 38 additions and 27 deletions

View File

@ -27,7 +27,7 @@ async function lookupFidByCustodyAddress(custodyAddress, apiKey) {
{ {
headers: { headers: {
'accept': 'application/json', 'accept': 'application/json',
'x-api-key': apiKey 'x-api-key': 'FARCASTER_V2_FRAMES_DEMO'
} }
} }
); );
@ -269,10 +269,17 @@ async function main() {
} }
// Try to get client ID from API // Try to get client ID from API
const appInfo = await queryNeynarApp(neynarApiKey); if (!neynarClientId) {
if (appInfo) { const appInfo = await queryNeynarApp(neynarApiKey);
neynarClientId = appInfo.app_uuid; if (appInfo) {
console.log('✅ Fetched Neynar app client ID'); neynarClientId = appInfo.app_uuid;
console.log('✅ Fetched Neynar app client ID');
break;
}
}
// We have a client ID (either from .env or fetched from API), so we can break out of the loop
if (neynarClientId) {
break; break;
} }
@ -366,6 +373,7 @@ async function main() {
// FID (if it exists in current env) // FID (if it exists in current env)
...(process.env.FID ? [`FID="${process.env.FID}"`] : []), ...(process.env.FID ? [`FID="${process.env.FID}"`] : []),
`NEXT_PUBLIC_USE_WALLET="${process.env.NEXT_PUBLIC_USE_WALLET || 'false'}"`,
// NextAuth configuration // NextAuth configuration
`NEXTAUTH_SECRET="${process.env.NEXTAUTH_SECRET || crypto.randomBytes(32).toString('hex')}"`, `NEXTAUTH_SECRET="${process.env.NEXTAUTH_SECRET || crypto.randomBytes(32).toString('hex')}"`,

View File

@ -2,7 +2,6 @@
"use client"; "use client";
import { useCallback, useEffect, useMemo, useState } from "react"; import { useCallback, useEffect, useMemo, useState } from "react";
import { Input } from "../components/ui/input";
import { signIn, signOut, getCsrfToken } from "next-auth/react"; import { signIn, signOut, getCsrfToken } from "next-auth/react";
import sdk, { import sdk, {
SignIn as SignInCore, SignIn as SignInCore,
@ -35,7 +34,7 @@ import { useMiniApp } from "@neynar/react";
import { PublicKey, SystemProgram, Transaction } from '@solana/web3.js'; import { PublicKey, SystemProgram, Transaction } from '@solana/web3.js';
import { Header } from "~/components/ui/Header"; import { Header } from "~/components/ui/Header";
import { Footer } from "~/components/ui/Footer"; import { Footer } from "~/components/ui/Footer";
import { USE_WALLET } from "~/lib/constants"; import { USE_WALLET, APP_NAME } from "~/lib/constants";
export type Tab = 'home' | 'actions' | 'context' | 'wallet'; export type Tab = 'home' | 'actions' | 'context' | 'wallet';
@ -191,7 +190,7 @@ export default function Demo(
const signTyped = useCallback(() => { const signTyped = useCallback(() => {
signTypedData({ signTypedData({
domain: { domain: {
name: "Frames v2 Demo", name: APP_NAME,
version: "1", version: "1",
chainId, chainId,
}, },
@ -199,7 +198,7 @@ export default function Demo(
Message: [{ name: "content", type: "string" }], Message: [{ name: "content", type: "string" }],
}, },
message: { message: {
content: "Hello from Frames v2!", content: `Hello from ${APP_NAME}!`,
}, },
primaryType: "Message", primaryType: "Message",
}); });
@ -243,7 +242,7 @@ export default function Demo(
cast={{ cast={{
text: "Check out this awesome frame @1 @2 @3! 🚀🪐", text: "Check out this awesome frame @1 @2 @3! 🚀🪐",
bestFriends: true, bestFriends: true,
embeds: [`${APP_URL}/share?fid=${context?.user?.fid || 'unknown'}`] embeds: [`${process.env.NEXT_PUBLIC_URL}/share/${context?.user?.fid || ''}`]
}} }}
className="w-full" className="w-full"
/> />
@ -252,10 +251,10 @@ export default function Demo(
<Button onClick={() => actions.openUrl("https://www.youtube.com/watch?v=dQw4w9WgXcQ")} className="w-full">Open Link</Button> <Button onClick={() => actions.openUrl("https://www.youtube.com/watch?v=dQw4w9WgXcQ")} className="w-full">Open Link</Button>
<Button onClick={actions.close} className="w-full">Close Frame</Button> <Button onClick={actions.close} className="w-full">Close Mini App</Button>
<Button onClick={actions.addMiniApp} disabled={added} className="w-full"> <Button onClick={actions.addMiniApp} disabled={added} className="w-full">
Add frame to client Add Mini App to Client
</Button> </Button>
{sendNotificationResult && ( {sendNotificationResult && (

View File

@ -26,17 +26,18 @@ interface ShareButtonProps {
export function ShareButton({ buttonText, cast, className = '', isLoading = false }: ShareButtonProps) { export function ShareButton({ buttonText, cast, className = '', isLoading = false }: ShareButtonProps) {
const [isProcessing, setIsProcessing] = useState(false); const [isProcessing, setIsProcessing] = useState(false);
const [bestFriends, setBestFriends] = useState<{ fid: number; username: string; }[] | null>(null); const [bestFriends, setBestFriends] = useState<{ fid: number; username: string; }[] | null>(null);
const [isLoadingBestFriends, setIsLoadingBestFriends] = useState(false);
const { context, actions } = useMiniApp(); const { context, actions } = useMiniApp();
// Fetch best friends if needed // Fetch best friends if needed
useEffect(() => { useEffect(() => {
if (cast.bestFriends && context?.user?.fid) { if (cast.bestFriends && context?.user?.fid) {
setIsProcessing(true); setIsLoadingBestFriends(true);
fetch(`/api/best-friends?fid=${context.user.fid}`) fetch(`/api/best-friends?fid=${context.user.fid}`)
.then(res => res.json()) .then(res => res.json())
.then(data => setBestFriends(data.bestFriends)) .then(data => setBestFriends(data.bestFriends))
.catch(err => console.error('Failed to fetch best friends:', err)) .catch(err => console.error('Failed to fetch best friends:', err))
.finally(() => setIsProcessing(false)); .finally(() => setIsLoadingBestFriends(false));
} }
}, [cast.bestFriends, context?.user?.fid]); }, [cast.bestFriends, context?.user?.fid]);
@ -47,16 +48,21 @@ export function ShareButton({ buttonText, cast, className = '', isLoading = fals
let finalText = cast.text || ''; let finalText = cast.text || '';
// Process best friends if enabled and data is loaded // Process best friends if enabled and data is loaded
if (cast.bestFriends && bestFriends) { if (cast.bestFriends) {
// Replace @N with usernames if (bestFriends) {
finalText = finalText.replace(/@\d+/g, (match) => { // Replace @N with usernames, or remove if no matching friend
const friendIndex = parseInt(match.slice(1)) - 1; finalText = finalText.replace(/@\d+/g, (match) => {
const friend = bestFriends[friendIndex]; const friendIndex = parseInt(match.slice(1)) - 1;
if (friend) { const friend = bestFriends[friendIndex];
return `@${friend.username}`; if (friend) {
} return `@${friend.username}`;
return match; }
}); return ''; // Remove @N if no matching friend
});
} else {
// If bestFriends is not loaded but bestFriends is enabled, remove @N patterns
finalText = finalText.replace(/@\d+/g, '');
}
} }
// Process embeds // Process embeds
@ -99,14 +105,12 @@ export function ShareButton({ buttonText, cast, className = '', isLoading = fals
} }
}, [cast, bestFriends, context?.user?.fid, actions]); }, [cast, bestFriends, context?.user?.fid, actions]);
const isButtonDisabled = cast.bestFriends && !bestFriends;
return ( return (
<Button <Button
onClick={handleShare} onClick={handleShare}
className={className} className={className}
isLoading={isLoading || isProcessing} isLoading={isLoading || isProcessing}
disabled={isButtonDisabled} disabled={isLoadingBestFriends}
> >
{buttonText} {buttonText}
</Button> </Button>