From bbff66fda2a1622f7d5585a0e942bda1a903467a Mon Sep 17 00:00:00 2001 From: Codex723 Date: Mon, 13 Jul 2026 00:32:22 +0100 Subject: [PATCH 1/2] feat: replace createTestnetAccount() stub with real Keypair + Friendbot funding - Generate a real Keypair via Keypair.random() - Fund the account via Friendbot on testnet (GET https://friendbot.stellar.org?addr=) - Handle Friendbot HTTP errors (e.g. already funded) and network failures gracefully - Return publicKey/secretKey pair on success or failure Closes #4 --- src/lib/stellar.ts | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/src/lib/stellar.ts b/src/lib/stellar.ts index d3e58d5..e647107 100644 --- a/src/lib/stellar.ts +++ b/src/lib/stellar.ts @@ -24,16 +24,41 @@ export async function createTestnetAccount(): Promise<{ publicKey: string; secretKey: string; }> { - // TODO(contributor): Generate a Keypair.random(), fund via Friendbot - // (https://friendbot.stellar.org?addr= for testnet), - // return the publicKey and secretKey. Do NOT store the secretKey server-side - // in production — return it to the client once so the user can save it. - console.warn("[STUB] createTestnetAccount returning mock keypair"); const keypair = Keypair.random(); - return { - publicKey: keypair.publicKey(), - secretKey: keypair.secret(), - }; + const publicKey = keypair.publicKey(); + const secretKey = keypair.secret(); + + // Only attempt Friendbot funding on testnet + if (NETWORK === "testnet") { + const friendbotUrl = `https://friendbot.stellar.org?addr=${publicKey}`; + console.log(`[createTestnetAccount] Funding ${publicKey} via Friendbot...`); + + try { + const response = await fetch(friendbotUrl, { method: "GET" }); + + if (!response.ok) { + // Friendbot returns 400+ when the account is already funded or on error. + // We treat this as non-fatal — the keypair is still valid. + const body = await response.text(); + console.warn( + `[createTestnetAccount] Friendbot responded with ${response.status}: ${body}` + ); + } else { + const result = await response.json(); + console.log( + `[createTestnetAccount] Friendbot success: hash=${result.hash}` + ); + } + } catch (err) { + // Network errors, timeouts, etc. — log and continue. + console.warn( + `[createTestnetAccount] Friendbot request failed:`, + err + ); + } + } + + return { publicKey, secretKey }; } // TODO(contributor): implement Horizon polling or streaming to resolve From e4511738afa80f7e082b340324982f3570df0962 Mon Sep 17 00:00:00 2001 From: Codex723 Date: Mon, 13 Jul 2026 00:41:00 +0100 Subject: [PATCH 2/2] fix: resolve ESLint errors across the codebase --- src/app/(app)/rates/page.tsx | 2 +- src/app/(app)/review/page.tsx | 2 +- src/app/api/stellar/send/route.ts | 9 +++++---- src/app/api/stellar/submit/route.ts | 5 +++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/app/(app)/rates/page.tsx b/src/app/(app)/rates/page.tsx index fc4cbe7..bc6c892 100644 --- a/src/app/(app)/rates/page.tsx +++ b/src/app/(app)/rates/page.tsx @@ -483,7 +483,7 @@ export default function RatesPage() {

Alert Created

- We'll notify you at the threshold + We will notify you at the threshold