fix(web): remove fake vouch XDR, externalize config, drop node-crypto fallback, split bundle - #100
Merged
Conversation
… fallback, split bundle
Resolve four code-lapse issues surfaced in the CI/quality pass:
- Vouch signing theater: Vouch.tsx and MentorDashboard.tsx fabricated a
random XDR string and asked Freighter to sign it, then discarded the
signature entirely — a blind-sign trust hazard that accomplished nothing.
Vouch approval is an authenticated, off-chain backend transition
(POST /vouching/approve, authorized by the mentor's wallet-bound JWT), so
the bogus signing step is removed and the handlers call the mutation
directly. Dead txHash plumbing dropped from useOptimisticVouch and
vouching.service. If on-chain vouching is ever wired up, it should route
through useTransaction + a backend-built XDR the way deposits do — never a
client-fabricated one.
- Hardcoded config: API_BASE_URL, STELLAR_NETWORK and the five CONTRACT_IDS
now read from VITE_* env vars with testnet defaults, matching the existing
SOROBAN_RPC_URL pattern that .env.example already advertised but the code
ignored. .env.example documents every variable.
- Browser-incompatible crypto: soroban.service computeSha256 dropped its
`await import('crypto')` Node fallback, which triggered Vite's "'crypto'
externalized for browser compatibility" warning and emitted a
__vite-browser-external chunk. Web Crypto (crypto.subtle) is the single
portable SHA-256 path across secure browser contexts and Node 19+.
- Monolithic bundle: the router now lazy-loads every route page, so the
Stellar SDK and other heavy per-page deps leave the initial chunk. Initial
entry drops from ~2,008 kB (565 kB gzip) to 386 kB (124 kB gzip); stellar-sdk
is isolated in a lazy chunk loaded only on the pages that need it.
Verified: eslint clean, 49/49 vitest pass, production build green with the
crypto externalization warning gone.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
Resolves four code-lapse issues found during the CI/quality pass on StepFi-Web. Each was code that either lied about what it did, hardcoded environment-specific values, or degraded the build — exactly the kind of lapse the quality pass exists to catch.
Changes
1. Removed vouch signing theater (correctness + trust)
Vouch.tsxandMentorDashboard.tsxbuilt a random, fabricated XDR string, asked Freighter to sign it, then discarded the signature. It accomplished nothing functional and trained mentors to blind-sign arbitrary payloads — a real trust hazard.Vouch approval is an authenticated, off-chain backend operation:
POST /vouching/approvetransitions the vouch recordPENDING → APPROVED, authorized by the mentor's wallet-bound JWT (established once at wallet-connect time). There is no transaction to sign, so the signing step is removed and the handlers call the mutation directly. DeadtxHashplumbing is dropped fromuseOptimisticVouchandvouching.service.2. Externalized hardcoded config
API_BASE_URL,STELLAR_NETWORKand the fiveCONTRACT_IDSwere hardcoded. They now read fromVITE_*env vars with testnet defaults — matching the existingSOROBAN_RPC_URLpattern that.env.examplealready advertised but the code ignored..env.examplenow documents every variable.3. Dropped browser-incompatible crypto fallback
soroban.servicecomputeSha256had anawait import('crypto')Node fallback that triggered Vite's "'crypto' externalized for browser compatibility" warning and emitted a__vite-browser-externalchunk. Web Crypto (crypto.subtle) is the single portable SHA-256 path across secure browser contexts and Node 19+, so it is now the only path.4. Split the monolithic bundle
The router now lazy-loads every route page, so the Stellar SDK and other heavy per-page dependencies leave the initial chunk.
The residual >500 kB warning on the isolated stellar-sdk chunk is left as-is on purpose — it is an honest signal about a genuinely large dependency, not something to silence with
chunkSizeWarningLimit.Test plan
npm run lint— cleannpm run test— 49/49 pass (10 files)npm run build— green; crypto externalization warning gone; initial entry 386 kBFollow-up (not in this PR)
handleDeclinein the vouch views is still a stubbed 600 ms timeout with no backend decline endpoint to call. Left as-is here — it needs an API endpoint before it can be wired up. Flagging for a future issue.