Skip to content

Feature/issue 5 persist stellar publickey - #26

Closed
Codex723 wants to merge 49 commits into
mainfrom
feature/issue-5-persist-stellar-publickey
Closed

Feature/issue 5 persist stellar publickey#26
Codex723 wants to merge 49 commits into
mainfrom
feature/issue-5-persist-stellar-publickey

Conversation

@Codex723

Copy link
Copy Markdown
Collaborator

Pull Request Summary

Branch: feature/persist-stellar-publickey

Changes Made

  1. Main Implementation (src/app/api/stellar/account/route.ts):

    • Added db import from @/lib/db
    • Added check for existing stellarPublicKey - returns 409 Conflict if user already has one
    • Added db.user.update() call to persist the stellarPublicKey to the user record after createTestnetAccount() succeeds
    • Removed the TODO(contributor) comment since the feature is now implemented
  2. Test Suite (src/app/api/stellar/account/route.test.ts):

    • Created comprehensive test suite with 4 test cases covering all acceptance criteria:
      • Returns 401 when user is not authenticated
      • Returns 409 when user already has a stellarPublicKey
      • Creates a Stellar account and updates user record when user has no stellarPublicKey
      • Returns 500 when createTestnetAccount fails
  3. Infrastructure:

    • Added vitest.config.ts for test configuration
    • Added src/test/setup.ts for test environment setup
    • Updated package.json with test and test:api scripts
    • Updated .github/workflows/backendci.yml to run API tests in CI
    • Added .github/workflows/contracts.yml for Rust/Soroban contract tests
    • Added .github/workflows/frontend.yml for frontend CI (lint, test, build)
  4. Bug Fixes:

    • Fixed pre-existing contract compilation errors in contracts/escrow/src/lib.rs (added .clone() to escrow_id in release() and refund() functions)
    • Fixed pre-existing test file errors in contracts/escrow/src/test.rs (removed unused imports)
    • Updated .gitignore to include Rust and vitest directories

Acceptance Criteria

  • User.stellarPublicKey is set after calling POST /api/stellar/account
  • Returns 409 if user already has a stellarPublicKey
  • Covered by a route test

How to Test

Run npm run test to execute the test suite.

Closes #5

Codex723 and others added 30 commits May 18, 2026 23:47
Update various files with fixes and changes
…on to let Next.js builder handle it automatically
fix vercel.json and update package-lock.json
- Prisma schema with User, Transaction, Rate models (CockroachDB)
- Auth: register/login/logout/me with bcrypt + JWT + httpOnly cookies
- Middleware protecting authenticated routes
- Stellar: create account (Friendbot), fetch rates (Horizon + fallback),
  build path_payment_strict_send XDR, submit signed XDR
- Wire Send page: live rate from /api/stellar/rate
- Wire Review page: client-side XDR signing (testnet-only shortcut)
  + submit to /api/stellar/submit
- Wire Activity page: real transactions from /api/transactions
- Wire Dashboard page: real transaction count and recent activity
- Login/Register page with reusable design system
- Zod validation on all API routes
- Build compiles with zero errors (20 routes)
- Add src/lib/rates.ts - core price engine (CoinGecko + Frankfurter APIs)
- Wire fetchRate() in stellar.ts to the real price engine
- Update rate API route to return full metadata
- Add cron endpoint for Vercel Cron Jobs
- Configure vercel.json with periodic cron schedule
- Update rates page to fetch live data from the API with auto-refresh

Cache chain: Fresh DB cache (< 5 min) -> API fetch -> Stale DB cache -> 1.00
Supports 21 crypto/fiat pairs routed through USD
Frankfurter API (European Central Bank) does NOT support African currencies
(NGN, XAF, XOF, GHS, KES, ZAR), so USD/NGN and all African pairs always
returned '1.00'.

Changes:
- Replace Frankfurter with ExchangeRate-API (free, no key, 150+ currencies
  including ALL African currencies)
- Cache the entire ExchangeRate-API response in memory (one fetch gets
  every forex rate at once, avoiding per-currency rate limit issues)
- Add hardcoded FALLBACK_RATES map so prices are realistic even when
  APIs are unreachable
- Remove src/app/api/cron/update-rates route and Vercel Cron config
  (paid feature) — in-memory cache auto-refreshes on first request
- Reduced nav item padding (py-2 instead of py-3) and text size (text-sm)
- Smaller icons (text-lg instead of default)
- Compact logo (9x9 vs 10x10) with gradient background
- Active state: full gradient background (primary->primary/70) with glow
  blur effect and left white accent bar
- Hover state: subtle primary gradient overlay with scale effect
- Added glass morphism to sidebar background (backdrop-blur-xl, 80% opacity)
- Added web3 keyframe animations (glowPulse, shimmerSweep, borderGlow)
- Smaller bottom section items with thinner borders
Codex723 and others added 19 commits July 12, 2026 00:09
This workflow installs Deno and runs linting and tests on push and pull request events.
…ot funding

- Generate a real Keypair via Keypair.random()
- Fund the account via Friendbot on testnet (GET https://friendbot.stellar.org?addr=<publicKey>)
- Handle Friendbot HTTP errors (e.g. already funded) and network failures gracefully
- Return publicKey/secretKey pair on success or failure

Closes #4
…account

feat: replace createTestnetAccount() stub with real Keypair + Friendbot funding
- Add db import and user update call in POST /api/stellar/account
- Return 409 Conflict if user already has a stellarPublicKey
- Add comprehensive route tests for the endpoint
- Add vitest config and test setup
- Update CI workflow to run API tests
- Fix pre-existing contract compilation errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Persist generated stellarPublicKey to the User record

1 participant