Skip to content

7.8 - Fix demo seed scripts: resolve pnpm module layout, read network from env - #174

Open
Otfrugger wants to merge 1 commit into
determined-001:mainfrom
Otfrugger:fix/demo-seed-scripts
Open

7.8 - Fix demo seed scripts: resolve pnpm module layout, read network from env#174
Otfrugger wants to merge 1 commit into
determined-001:mainfrom
Otfrugger:fix/demo-seed-scripts

Conversation

@Otfrugger

Copy link
Copy Markdown
Contributor

closes #161

Summary

pnpm demo:seed failed outright, and even fixed it could only ever seed testnet.

1. Module resolution

scripts/demo-seed.ts / demo-reset.ts lived at the repo root and import @stellar/stellar-sdk, which pnpm's strict node_modules layout doesn't let a root-level script resolve. Moved both — plus their shared lib/env.ts and lib/sep10-login.ts helpers — under apps/api/scripts/, following the precedent already set by apps/api/scripts/gen-mainnet-secrets.mjs (whose own header comment explains exactly this constraint). Updated the root demo:seed/demo:reset package.json scripts to run them via pnpm --filter @checkout/api exec tsx scripts/..., matching how secrets:mainnet already invokes gen-mainnet-secrets.mjs.

2. Network hardcoding

demo-seed.ts hardcoded Networks.TESTNET and Friendbot, and refused to run unless GET /health reported "testnet". It now:

  • Reads STELLAR_NETWORK (default testnet), HORIZON_URL, and USDC_ISSUER_PUBLIC/USDC_ISSUER_TESTNET the same way apps/api/src/env.ts does — via @checkout/stellar's resolveStellarConfig, so the defaults can never drift out of sync with what the API itself uses.
  • Cross-checks its own configured network against the live API's GET /health response and fails with a clear message on mismatch (was previously a hardcoded "testnet" comparison).
  • Skips the Friendbot XLM funding step and the testanchor USDC-dispenser step on any non-testnet network, each with an explicit [skip] message, since neither exists off testnet. It doesn't invent an alternative funding mechanism (out of scope) — if the buyer keypair isn't funded some other way, the payment step fails with the real Horizon error (e.g. account-not-found) rather than an obscure one, which is what the issue's acceptance criterion ("works or refuses with a clear reason") asks for.

3. Demo link id

The /demo storefront page's widget button has always linked to data-quay-link="demo_mug_123" (apps/web/app/demo/page.tsx) — but link ids are always a random lnk_... string server-side, so that id could never resolve to a real link (confirmed via git blame, this has been broken since the page's introduction). createLinkSchema (packages/core/src/schemas.ts) now accepts an optional custom id, but rejects it unless isDemo: true is also set, so a real payment link can never be given a predictable id. demo-seed.ts seeds (idempotently — checks GET /links/demo_mug_123 first) a $25.00 link with that exact id, left unpaid so a real visitor can pay it through the widget.

Also updated

  • README.md, docs/MAINNET.md, TODO.md — removed/updated the now-stale "testnet-only" caveats.
  • apps/api/test/routes/links.test.ts — added coverage for the new id/isDemo schema behavior (custom id accepted with isDemo:true, rejected without it, rejected on bad characters).

Verification

  • Read through the full script logic and the resolveStellarConfig/env.ts defaults it now reuses to confirm they match.
  • Byte-scanned every changed file for stray control bytes before committing.
  • Could not run: no pnpm/node_modules install is available in this environment, so I could not run pnpm typecheck, pnpm test, or actually execute pnpm demo:seed against a live API. Please run those (and a real pnpm demo:seed against a local testnet API) before merging — this is unverified beyond careful manual review.

Caveats

  • apps/api/scripts isn't included in apps/api/tsconfig.json's typecheck (include: ["src", "test"]), same as before the move — these scripts were never typechecked by CI either as root-level files or now, so this isn't a regression, but flagging it in case that's worth fixing separately.
  • The custom-id schema change is a small, deliberately-scoped API surface addition beyond what the issue's "Key files" list mentioned (packages/core/src/schemas.ts, apps/api/src/services/link-service.ts) — needed to actually seed demo_mug_123. Happy to split it out if preferred.

…from env

pnpm demo:seed failed outright: scripts/demo-seed.ts and demo-reset.ts lived
at the repo root and imported @stellar/stellar-sdk, which pnpm's strict
node_modules layout does not let a root-level script resolve. Move both (and
their shared lib/env.ts, lib/sep10-login.ts helpers) under apps/api/scripts/,
matching the apps/api/scripts/gen-mainnet-secrets.mjs precedent, and update
the root demo:seed/demo:reset package.json scripts to run them via
.

demo-seed.ts also hardcoded Networks.TESTNET and Friendbot, so it could only
ever seed testnet. It now reads STELLAR_NETWORK/HORIZON_URL/USDC_ISSUER_*
the same way apps/api/src/env.ts does (via @checkout/stellar's
resolveStellarConfig, so the defaults can't drift from what the API itself
uses), defaulting to testnet. Friendbot and the testanchor USDC dispenser
only exist on testnet, so on any other network those steps are skipped with
an explicit message instead of failing obscurely deeper in the script; the
API's own STELLAR_NETWORK is cross-checked against /health so a
misconfigured pairing is caught immediately.

Also seeds a link with the fixed id demo_mug_123 that the /demo storefront
page's widget button has always linked to (apps/web/app/demo/page.tsx) but
that no real link could ever have, since ids were always a random lnk_...
string. createLinkSchema now accepts an optional custom id, but only
together with isDemo:true, so a real payment link can never get a
predictable id.
@drips-wave

drips-wave Bot commented Aug 28, 2026

Copy link
Copy Markdown

@Otfrugger 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! 🚀

Learn more about application limits

@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

@Otfrugger is attempting to deploy a commit to the determined's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

7.8 - The demo seed scripts cannot run, and only know testnet

1 participant