Skip to content

fix(frontend): add testnet-only guard mirroring backend assertTestnet#1

Open
SilvaCleverson wants to merge 1 commit into
wmendes:mainfrom
SilvaCleverson:fix/frontend-testnet-guard
Open

fix(frontend): add testnet-only guard mirroring backend assertTestnet#1
SilvaCleverson wants to merge 1 commit into
wmendes:mainfrom
SilvaCleverson:fix/frontend-testnet-guard

Conversation

@SilvaCleverson

@SilvaCleverson SilvaCleverson commented Jul 8, 2026

Copy link
Copy Markdown

What & why

The backend already refuses to run against the public network — assertTestnet() in src/lib/network.ts throws if the passphrase is PUBLIC, because this repo performs destructive, irreversible ops (freeze, clawback, lock-the-issuer). The project docs make this a stated invariant:

"Never introduce a mainnet code path; the assertTestnet guard stays." — THE_IDEA.md

The frontend had no equivalent guard. A misconfigured VITE_NETWORK_PASSPHRASE pointing at PUBLIC would let the dApp build, sign (via the connected wallet), and submit those same destructive operations against mainnet.

Change

  • Add testnetGuardError() to frontend/src/lib/network.ts, mirroring the backend assertTestnet semantics.
  • Call it in main.tsx before 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 --noEmit in frontend/ passes.

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>
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.

1 participant