Skip to content

feat: persist stellarPublicKey to User record after account creation#25

Open
Codex723 wants to merge 5 commits into
mainfrom
feature/persist-stellar-publickey
Open

feat: persist stellarPublicKey to User record after account creation#25
Codex723 wants to merge 5 commits into
mainfrom
feature/persist-stellar-publickey

Conversation

@Codex723

Copy link
Copy Markdown
Collaborator

TITLE: Persist generated stellarPublicKey to the User record

Description

This PR implements issue #5 to persist the generated stellarPublicKey to the User record after calling createTestnetAccount().

Changes

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

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

Infrastructure

  • vitest.config.ts: Added Vitest configuration for test configuration
  • src/test/setup.ts: Added test environment setup
  • package.json: Added test and test:api scripts
  • .github/workflows/backendci.yml: Updated to run API tests in CI

Bug Fixes

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

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.

Codex723 added 2 commits July 14, 2026 13:08
- 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
@Codex723
Codex723 force-pushed the feature/persist-stellar-publickey branch from 017807c to 953eeea Compare July 14, 2026 12:16
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.

1 participant