Skip to content

Make the offramp order endpoint idempotent, and test it #187

Closed

Description

@Miracle656

Background

src/api/offramp.ts has no test file, and it is the only money-moving router in the repo.

POST /offramp/orders does a findUnique on the idempotency key (:171), creates the order at the provider (:191), then inserts the row (:208). Two concurrent taps both miss the findUnique; the provider dedupes, but the second create violates @@unique([network, idempotencyKey]) (prisma/schema.prisma:420) and falls into sendLinqError as a bare 500 — even though the order exists and is fine.

Amounts are unvalidated: Number(amountNGN) at :192 turns "abc" into NaN, and accepts negatives and Infinity.

Acceptance criteria

  • The pre-check and insert become an idempotent upsert, or P2002 is caught and the existing row returned as replayed: true
  • Amounts validated with zod — positive, finite, within a configured bound; bad input returns 400 before any provider call
  • Route tests with a mocked provider client: happy path, replay, concurrent duplicate returns 200 not 500, amountNGN: "abc" returns 400
  • No user-facing message names the payment provider

Drips Wave · Complexity: Intermediate · 150 points


How this repo is laid out

Wraith is a Soroban incoming-transfer indexer: it fills the gap Horizon leaves for SAC/SEP-41 token events by recipient address. Roughly 14k lines under src/, REST + GraphQL + WebSocket, Postgres via Prisma, deployed on Render.

  • Unit tests are jest (src/**/__tests__, tests/*.test.ts), with a coverage gate.
  • Integration tests are vitest (tests/integration/, vitest.integration.config.ts, Docker).
  • Don't mix the two runners in one file.

Known state of main before you start

tsc --noEmit and the unit suite are green. The Integration tests CI job is red, and so is Load test — both predate this batch. Open PRs #177 and #178 address them. If the integration job is red when you open a PR, that is not your fault; say so in the PR and carry on.

Four modules are shipped, closed as done, and imported by nothing: src/indexer/checkpoint.ts, src/ingest/reorg.ts, src/middleware/opa.ts, and src/api/candles.ts + src/workers/ohlc-refresh.ts. So the live indexer today has no reorg handling and no atomic checkpointing, despite both features being closed. Two issues below start unpicking that — don't assume a closed issue means a wired feature.

Ground rules

  • Every PR needs a test that fails before the change and passes after, unless the issue says otherwise.
  • Don't widen a Prometheus label to something unbounded — addresses and contract ids must never become label values.
  • Nothing may log or return a raw database error, a connection string, or a provider URL.
  • Don't reformat a file you're changing. A diff that is 90% whitespace hides the 10% that matters.


Required: Before submitting, join the contributor Telegram so your work can be tracked and counted toward the Stellar Wave: https://t.me/+fxHXq8f1SwlkZDBk

Activity

  1. ojuotimi932 commented on Sep 24, 2026

    @ojuotimi932

    @ojuotimi932 has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    Hi Maintainer, can i resolve this. Kindly assign

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @ojuotimi932 to this issue.

  2. shotundeibrahimoluwaseyifunmi-ship-it commented on Sep 24, 2026

    @shotundeibrahimoluwaseyifunmi-ship-it

    @shotundeibrahimoluwaseyifunmi-ship-it has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    Hi Maintainer, I’d like to work on this issue. I have experience with similar tasks and believe I can contribute effectively. I’m available to start immediately and would be happy to take it on.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @shotundeibrahimoluwaseyifunmi-ship-it to this issue.

  3. Adedoyinjr commented on Sep 25, 2026

    @Adedoyinjr

    @Adedoyinjr has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    Hello, I’d like to pick up issue #187.

    I’ll make the offramp order flow safely idempotent by handling the race between the existing lookup, provider creation, and database insert, ensuring concurrent requests return the existing order instead of a 500.

    I’ll also add Zod validation for "amountNGN" so invalid, negative, infinite, or out-of-bound amounts are rejected before any provider call.

    I’ll create focused route tests with a mocked provider covering the happy path, replay, concurrent duplicates, and invalid amounts. I’ll also verify that user-facing errors never expose provider details.

    I’ll keep the changes scoped to the offramp flow and run the required tests and type checks before submitting.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Adedoyinjr to this issue.

  4. Glorious21 commented on Sep 26, 2026

    @Glorious21
    Contributor

    @Glorious21 has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    Hi Maintainer, I am an excellent Web Developer. I love collaborating and contributing to valuable and viable project like this.
    I would appreciate and execute the task excellently, if you can assign this issue to me.
    I will deliver up to your expectation. Thanks

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Glorious21 to this issue.

  5. drips-wave commented on Sep 26, 2026

    @drips-wave

    Congratulations, @Glorious21! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on September 30, 2026.

    🧑‍💻 @Glorious21: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

    Warning

    When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

    🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

    🌊 Happy Wave 🌊

  6. added a commit that references this issue on Oct 16, 2026
    5ba5a8e
  7. drips-wave commented on Oct 19, 2026

    @drips-wave

    This issue has been completed by @Glorious21 as part of the Stellar Wave Program's 10th Wave 🥳

    😎 @Glorious21: You earned 150 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

    🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

  8. added a commit that references this issue on Oct 19, 2026
    ef92e7a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions