Repository navigation
Conversation
Add a per-environment asset allowlist (USDC + native XLM) with a token-agnostic amount, payee trustline checks, and the prepare half of the non-custodial flow: an unsigned create_escrow XDR, new awaiting_signature state, and an expiry sweep back to created. Closes DocForum#79 Closes DocForum#80 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@habeebti Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
@habeebti Thanks for the PR. It can't be merged yet. To unblock it: Merge conflicts: this branch conflicts with Push to this same branch and CI will re-run. Once it's green and conflict-free, it'll be reviewed for merge. |
|
@habeebti This PR now has merge conflicts with git fetch upstream # upstream = https://github.com/DocForum/docforum-core.git
git rebase upstream/main
# resolve the conflicts, re-run the tests, then:
git push --force-with-leaseThe usual culprits are shared files like Automated message. It won't repeat unless the PR conflicts again after your next push. |
|
@habeebti CI is failing on this branch (after it was updated with the latest The new |
|
@habeebti This PR now has merge conflicts with git fetch upstream # upstream = https://github.com/DocForum/docforum-core.git
git rebase upstream/main
# resolve the conflicts, re-run the tests, then:
git push --force-with-leaseThe usual culprits are shared files like Automated message. It won't repeat unless the PR conflicts again after your next push. |
What changed
Closes #79
Closes #80
Payment assets (issue #79)
PaymentIntentnow storesassetCode+tokenContractId, andamountStroopsis renamed to the token-agnosticamount. The migration is a plain column rename plus a nullabletokenContractIdbackfill — existing rows keep their exact value and resolve native XLM fromESCROW_TOKEN_ID(documented legacy fallback). No code still assumes “stroops of XLM”.PAYMENT_ASSETSis a per-environment allowlist (JSON:{ code, tokenContractId, decimals, issuer? }). Testnet defaults are native XLM + USDC SACs; production must set it explicitly. Entries opting into clawback/rebasing are rejected (escrow threat model T5). An intent in any other asset is400 UNSUPPORTED_PAYMENT_ASSET.decimalsis carried for clients only.409 PAYEE_TRUSTLINE_MISSINGand happens before any SDK/on-chain call. Native XLM skips the check.PAYMENT_TESTNET_USDC=true) USDC fund→release case.Prepare endpoint (issue #80)
POST /payments/intents/:id/prepare: patient-only, verified email, and ownership is enforced in the service (someone else's intent is404, not403). Requires a verifiedPatientWalletLink(409 WALLET_NOT_LINKED) and a linked facility payee (409 FACILITY_WALLET_NOT_LINKED).create_escrowvia the SDK seam, storespreparedTxHash/preparedXdr/preparedExpiryLedger/preparedExpiresAt, and movescreated → awaiting_signaturewith a conditional UPDATE in the same transaction as its AuditEvent.refundAfter= order expiry + configurable grace. Orders have no expiry field yet (Phase 4 placeholder), so the intent'screatedAtis the documented anchor; it is never set in the past.awaiting_signature/submittingenum values; an interval job (src/jobs/payment-intents.ts) sweeps expired prepared transactions back tocreatedas a normal case and recordspayment_intent.prepare_expired.Docs
ROADMAP (items + changelog), ARCHITECTURE §3/§4.10/new §4.12, ARCHITECTURE_ESSENTIALS (payments + gaps), docs/api (payments routes, state machine, env knobs, export v2), ADR 0004 update, ADR 0005 implementation notes/status, .env.example, jobs README.
Verification
backend/:npm run typecheck✅,npm run build✅,npm test→ 9 files / 93 tests ✅,npm run test:integration→ 10 files ✅ (includes newpayments-assetsandpayments-preparesuites covering allowlist, USDC vs XLM, trustline rejection, legacy fallback, prepare idempotency, expiry → re-prepare, wrong patient, missing wallet links).Assumptions / limitations (explicit)
@docforum/escrow-sdk0.3.0 (docforum-escrow [Phase 2] Rule-based red-flag symptom detection at intake with emergency guidance #58, docforum-core [Phase 5.5] Upgrade to @docforum/escrow-sdk 0.3.0 and the current testnet contract #32). This repo pins 0.2.0, which has no prepare call, so the endpoint returns503 ESCROW_SDK_PREPARE_UNSUPPORTEDagainst the real SDK instead of fabricating a transaction. The HTTP/DB state machine and tests are complete against the documented SDK contract; the mocked-SDK integration tests are the coverage the issue asks for.PatientWalletLinkis created by the SEP-10 flow, which is not built yet (ADR 0005 step 4). There is therefore no HTTP route to create one; prepare correctly returns409 WALLET_NOT_LINKEDuntil that lands.🤖 Generated with Codebuff