7.8 - Fix demo seed scripts: resolve pnpm module layout, read network from env - #174
Open
Otfrugger wants to merge 1 commit into
Open
7.8 - Fix demo seed scripts: resolve pnpm module layout, read network from env#174Otfrugger wants to merge 1 commit into
Otfrugger wants to merge 1 commit into
Conversation
…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.
|
@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! 🚀 |
|
@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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #161
Summary
pnpm demo:seedfailed outright, and even fixed it could only ever seed testnet.1. Module resolution
scripts/demo-seed.ts/demo-reset.tslived at the repo root and import@stellar/stellar-sdk, which pnpm's strictnode_moduleslayout doesn't let a root-level script resolve. Moved both — plus their sharedlib/env.tsandlib/sep10-login.tshelpers — underapps/api/scripts/, following the precedent already set byapps/api/scripts/gen-mainnet-secrets.mjs(whose own header comment explains exactly this constraint). Updated the rootdemo:seed/demo:resetpackage.jsonscripts to run them viapnpm --filter @checkout/api exec tsx scripts/..., matching howsecrets:mainnetalready invokesgen-mainnet-secrets.mjs.2. Network hardcoding
demo-seed.tshardcodedNetworks.TESTNETand Friendbot, and refused to run unlessGET /healthreported"testnet". It now:STELLAR_NETWORK(defaulttestnet),HORIZON_URL, andUSDC_ISSUER_PUBLIC/USDC_ISSUER_TESTNETthe same wayapps/api/src/env.tsdoes — via@checkout/stellar'sresolveStellarConfig, so the defaults can never drift out of sync with what the API itself uses.GET /healthresponse and fails with a clear message on mismatch (was previously a hardcoded"testnet"comparison).[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
/demostorefront page's widget button has always linked todata-quay-link="demo_mug_123"(apps/web/app/demo/page.tsx) — but link ids are always a randomlnk_...string server-side, so that id could never resolve to a real link (confirmed viagit blame, this has been broken since the page's introduction).createLinkSchema(packages/core/src/schemas.ts) now accepts an optional customid, but rejects it unlessisDemo: trueis also set, so a real payment link can never be given a predictable id.demo-seed.tsseeds (idempotently — checksGET /links/demo_mug_123first) a$25.00link 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 newid/isDemoschema behavior (custom id accepted withisDemo:true, rejected without it, rejected on bad characters).Verification
resolveStellarConfig/env.tsdefaults it now reuses to confirm they match.pnpm typecheck,pnpm test, or actually executepnpm demo:seedagainst a live API. Please run those (and a realpnpm demo:seedagainst a local testnet API) before merging — this is unverified beyond careful manual review.Caveats
apps/api/scriptsisn't included inapps/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.idschema 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 seeddemo_mug_123. Happy to split it out if preferred.