diff --git a/src/app/page.tsx b/src/app/page.tsx index 933555b..4ed1f68 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -43,7 +43,7 @@ const Page: React.FC = (): React.ReactElement => { const handleFluxGeneration = (modelId: string, cost: number) => { return async (prompt: string): Promise => { const type = walletState.type; - if (!walletState.connected || !walletState.publicKey || + if (!walletState.connected || !walletState.publicKey || !walletState.type || (type === 'phantom' && !window.phantom) || (type === 'solflare' && !window.solflare)) { return { error: 'Wallet not connected' } @@ -53,7 +53,7 @@ const Page: React.FC = (): React.ReactElement => { const paymentResult = await processMTMPayment( walletState.publicKey, cost, - walletState.type + walletState.type ) if (!paymentResult.success) { @@ -62,6 +62,10 @@ const Page: React.FC = (): React.ReactElement => { const transactionSignature = paymentResult.transactionSignature; + if (!transactionSignature) { + return { error: 'Transaction signature not found' } + } + // Then generate image with specified model return generateWithFlux(prompt, modelId, transactionSignature) } diff --git a/src/services/fluxService.ts b/src/services/fluxService.ts index 7f22c2e..e7698d3 100644 --- a/src/services/fluxService.ts +++ b/src/services/fluxService.ts @@ -16,19 +16,19 @@ export const FLUX_MODELS: FluxModelConfig[] = [ modelId: "fal-ai/flux/schnell", name: "Schnell", description: "Fast meme generator", - cost: 300 + cost: 0.1 }, { modelId: "fal-ai/recraft-v3", name: "Recraft", description: "Advanced meme generator", - cost: 400 + cost: 0.15 }, { modelId: "fal-ai/stable-diffusion-v35-large", name: "Marquee", description: "Best meme generator", - cost: 500 + cost: 0.2 } ] diff --git a/src/services/paymentService.ts b/src/services/paymentService.ts index a966b7a..ffd281e 100644 --- a/src/services/paymentService.ts +++ b/src/services/paymentService.ts @@ -1,3 +1,5 @@ +import assert from 'assert'; + import { Connection, PublicKey, Transaction } from '@solana/web3.js' import { TOKEN_PROGRAM_ID, @@ -5,8 +7,13 @@ import { createAssociatedTokenAccountInstruction, ASSOCIATED_TOKEN_PROGRAM_ID } from '@solana/spl-token' + import { WalletType } from './types' +assert(process.env.NEXT_PUBLIC_SOLANA_RPC_URL, 'SOLANA_RPC_URL is required'); +assert(process.env.NEXT_PUBLIC_MTM_TOKEN_MINT, 'MTM_TOKEN_MINT is required'); +assert(process.env.NEXT_PUBLIC_PAYMENT_RECEIVER_ADDRESS, 'PAYMENT_RECEIVER_ADDRESS is required'); + const MTM_TOKEN_MINT = process.env.NEXT_PUBLIC_MTM_TOKEN_MINT; const PAYMENT_RECEIVER_ADDRESS = process.env.NEXT_PUBLIC_PAYMENT_RECEIVER_ADDRESS; const SOLANA_RPC_URL = process.env.NEXT_PUBLIC_SOLANA_RPC_URL;