fix(frontend): add testnet-only guard mirroring backend assertTestnet#1
Open
SilvaCleverson wants to merge 1 commit into
Open
fix(frontend): add testnet-only guard mirroring backend assertTestnet#1SilvaCleverson wants to merge 1 commit into
SilvaCleverson wants to merge 1 commit into
Conversation
The backend refuses to run against the PUBLIC network (src/lib/network.ts assertTestnet), but the dApp had no equivalent guard: a misconfigured VITE_NETWORK_PASSPHRASE pointing at PUBLIC would let it sign and submit destructive ops (freeze, clawback, lock) on mainnet. Add testnetGuardError() to frontend network config and check it in main.tsx before mounting, rendering a visible error instead of silently signing. 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.
What & why
The backend already refuses to run against the public network —
assertTestnet()insrc/lib/network.tsthrows if the passphrase isPUBLIC, because this repo performs destructive, irreversible ops (freeze, clawback, lock-the-issuer). The project docs make this a stated invariant:The frontend had no equivalent guard. A misconfigured
VITE_NETWORK_PASSPHRASEpointing at PUBLIC would let the dApp build, sign (via the connected wallet), and submit those same destructive operations against mainnet.Change
testnetGuardError()tofrontend/src/lib/network.ts, mirroring the backendassertTestnetsemantics.main.tsxbefore mounting: if the configured passphrase is PUBLIC, render a visible error message instead of silently booting the app (fail-fast, no blank screen).No behavior change on testnet — the default and any correct testnet passphrase mount the app exactly as before.
Testing
npx tsc --noEmitinfrontend/passes.