Repository navigation
[1626] [frontend] Move Stellar Horizon, explorer, passphrase and price-API URLs into network config - #1700
Merged
Conversation
added 5 commits
October 19, 2026 07:02
…on failures (cherry picked from commit f384a0f)
(cherry picked from commit 4763ad4)
(cherry picked from commit 1c5e8e4)
… v4 API (cherry picked from commit dec5463)
Network passphrase, Horizon, explorer and price-API URLs were read or hard-coded in a dozen places, bypassing `config/network.ts`. - `config/network.ts` now owns `horizonUrl`, `explorerUrl`, `xlmPriceApiUrl`, per-network `horizonBaseUrls` / `stellarExplorerBaseUrls` and `getHorizonUrlForRpcUrl()`, each with a built-in default that can be overridden through `VITE_HORIZON_URL`, `VITE_STELLAR_EXPLORER_URL` and `VITE_XLM_PRICE_API_URL` - drop the direct `VITE_STELLAR_NETWORK_PASSPHRASE ?? ""` reads in `NetworkSwitchNotification`, `TransactionStatus` and `TransactionStatusModal`; they now derive the mode from `networkConfig.isTestnet` - route every Horizon call (`transactionApi`, `useTransactionTimeline`, `TransactionStatusModal`, `TransactionReceipt`, `stellarAccount`) through `networkConfig.horizonUrl` - `getStellarExplorerUrl()` builds links from `stellarExplorerBaseUrls`; `TransactionTimeline` uses it instead of inlining the URL and no longer renders a dead link for an invalid hash - move the CoinGecko price URL and the referral share endpoints into config modules - keep `ALLOWED_EXTERNAL_DOMAINS` in sync with the configured explorer and Horizon hosts so overrides do not break `sanitizeExternalLink` - document the new variables and their defaults in `.env.example` and `docs/ENV_VARIABLE_MATRIX.md` Closes 1626
| * fall back to the Horizon endpoint of the configured network. | ||
| */ | ||
| export function getHorizonUrlForRpcUrl(rpcUrl: string): string { | ||
| if (rpcUrl.includes(TESTNET_SOROBAN_RPC_HOST)) { |
| if (rpcUrl.includes(TESTNET_SOROBAN_RPC_HOST)) { | ||
| return horizonBaseUrls.testnet; | ||
| } | ||
| if (rpcUrl.includes(MAINNET_SOROBAN_RPC_HOST)) { |
|
@ToryMic 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 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 #1626
Closes 1626
Summary
Network passphrase, Horizon, Stellar Expert and price-API URLs were read (or
hard-coded) in a dozen places, bypassing the single network config. This PR makes
frontend/src/config/network.tsthe only source for them, removes theVITE_STELLAR_NETWORK_PASSPHRASE ?? ""fallbacks, and documents the newoverrides in
.env.example.Changes
config/network.tsis now the single sourcenetworkConfig.horizonUrlhorizon-testnet.stellar.org/horizon.stellar.orgVITE_HORIZON_URLnetworkConfig.explorerUrl,stellarExplorerBaseUrlsstellar.expert/explorer/testnet/…/publicVITE_STELLAR_EXPLORER_URLnetworkConfig.xlmPriceApiUrlsimple/price?ids=stellar&vs_currencies=usdVITE_XLM_PRICE_API_URLgetHorizonUrlForRpcUrl()solib/stellarAccount.tsno longer keeps itsown testnet/mainnet Horizon constants, and dropped its local RPC default in
favour of
networkConfig.rpcUrl.config/externalLinks.tsfor the referral share endpoints.Passphrase reads
NetworkSwitchNotification,TransactionStatusandTransactionStatusModalread
import.meta.env.VITE_STELLAR_NETWORK_PASSPHRASE ?? ""directly. They nowderive the mode from
networkConfig.isTestnet, so the passphrase is only everread in
config/network.ts:The dead
detectExpectedNetwork()helper inNetworkSwitchNotificationis gone(it also compared
"Testnet"with"testnet", so the testnet manual-steps branchwas unreachable; fixed while removing the env read).
Horizon
lib/transactionApi.ts,hooks/useTransactionTimeline.ts,components/TransactionStatusModal.tsx,pages/TransactionReceipt.tsxandlib/stellarAccount.tsall usenetworkConfig.horizonUrl(orgetHorizonUrlForRpcUrl) instead of a hard-coded testnet endpoint.Explorer
lib/security.ts#getStellarExplorerUrl()builds links fromstellarExplorerBaseUrlsinstead of two inline literals.components/TransactionTimeline.tsxnow callsgetStellarExplorerUrl()instead of building
https://stellar.expert/explorer/testnet/tx/…inline, anddoes not render the link when the hash fails validation (
getStellarExplorerUrlreturns
"#").pages/TransactionReceipt.tsxbuilds both the transaction and the ledger linkfrom the config (the ledger link previously pointed at
…/tx/ledger/<n>).ALLOWED_EXTERNAL_DOMAINSnow includes the configured explorer/Horizonhostnames so overriding them does not make
sanitizeExternalLink()return"#".Price API
lib/vaultApi.ts#getXlmPrice()usesnetworkConfig.xlmPriceApiUrl.Docs
frontend/.env.example: documented defaults + the three optional overrides.docs/ENV_VARIABLE_MATRIX.md: new rows / updated sources for the frontendStellar section (count updated in
ENVIRONMENT_SETUP_GUIDE.md).Tests
frontend/src/config/network.test.ts(new): testnet defaults, mainnetderivation from the passphrase,
VITE_overrides, and RPC → Horizon mapping.frontend/src/components/TransactionTimeline.test.tsx: asserts the explorerhrefequalsgetStellarExplorerUrl(hash, "testnet")for a valid 64-char hash,plus a new case proving no link is rendered for an invalid hash.
frontend/src/pages/TransactionHistory.test.tsx: the../config/networkmocknow spreads the real module so per-network explorer bases stay available.
Verification
TZ=UTC npx vitest run→ 129 files / 1381 tests passingnpm run lint→ 0 errors (37 pre-existing warnings, unchanged)npx tsc -b→ cleannpm run build→ exit 0npm run check-size→ 7/7 checks passedNotes
Contracts lint + test + build,Rust + WASM CI,Cargo Security Audit,Slither,NPM/PNPM Audit,GitHub Dependency ReviewandGovernance & PR Standards Validationfail identically onmain(verified againstthe current baseline PRs); they are unrelated to this change.