Repository navigation
feat: add wallet network selection (testnet/mainnet/custom) (#889) - #951
Open
adenueltech wants to merge 1 commit into
Open
adenueltech wants to merge 1 commit into
adenueltech wants to merge 1 commit into
Conversation
…tellar-split#889) - Add src/lib/networks.ts: presets, custom networks, stored preference, validation, live RPC passphrase check and explorer URL helpers - Resolve RPC, Horizon, passphrase, contract ID and USDC address from the active network in config/stellar/freighter and the components that hard-coded them, so endpoints are correct per network - Add NetworkSelector: always-visible badge in the navbar plus a dialog to switch; Mainnet needs explicit confirmation, custom networks must pass a getNetwork check, unconfigured presets are disabled - Warn when the Freighter wallet is on a different network than the app - Remove the static badge from NetworkStatus (now only RPC health) - Document optional per-network env vars in .env.example Closes Stellar-split#889 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
@adenueltech is attempting to deploy a commit to the kingsman-99's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@adenueltech 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! 🚀 |
This branch has not been deployed
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 #889
What changed
Before this PR, the network was fixed at build time through
NEXT_PUBLIC_STELLAR_NETWORKand read in about 20 separate places. Users can now switch between Testnet, Mainnet and a Custom network in the app.Network switching logic and stored preference:
src/lib/networks.tslocalStorage(stellarsplit_network).getActiveNetwork()returns the saved choice in the browser and the build default otherwise, including on the server.splitClientare rebuilt for the new network. No stale RPC or contract client can leak across.Endpoints correct per network
config.ts,stellar.tsandfreighter.tsnow resolve RPC, Horizon, passphrase, contract ID and USDC from the active network. Existing exports (RPC_URL,NETWORK_PASSPHRASE,USDC_CONTRACT_ID, …) are unchanged, so callers keep working.NEXT_PUBLIC_STELLAR_NETWORK/NEXT_PUBLIC_RPC_URLternaries in the client components and hooks (explorer links, Horizon polling, invoice stream, debugger, etc.)./paymentspreviously always linked to the testnet explorer.NEXT_PUBLIC_{TESTNET,MAINNET}_{CONTRACT_ID,RPC_URL,HORIZON_URL,USDC_ADDRESS}(documented in.env.example). The un-prefixed vars apply only to the default network, so a testnet contract ID is never reused on mainnet.Validate network compatibility
StrKey. They must also pass a livegetNetworkRPC call that reports the same passphrase before the switch is allowed.getNetworkDetails).Current network always visible, no accidental mainnet/testnet confusion
NetworkSelectorbadge in the navbar, now shown at every breakpoint. The old static badge was hidden belowsm. It is colour-coded and opens the switch dialog.NetworkStatuskeeps the RPC health dot and now checks the active network's RPC.Notes
How I tested
src/__tests__/networks.test.ts: presets, stored preference (including corrupt values), custom network validation and resolution, RPC passphrase check (match, mismatch, HTTP error, unreachable) and explorer URLs.npx tsc --noEmit: 0 errors.next linton all changed files: clean.vitest run: 2141 passed, 5 failed. The 5 failures (ErrorBoundary,InvoiceExportButton,SubscriptionCard,brandTools,contractEvents) also fail or are flaky on unmodifiedmainand are unrelated to this change.🤖 Generated with Claude Code