Repository navigation
refactor: consolidate Stellar network config into a single source (#489) - #621
Merged
nonsobethel0-dev merged 2 commits intoSep 23, 2026
Conversation
Add IS_MAINNET, NETWORK_PASSPHRASES, NETWORK_PASSPHRASE, NETWORK_LABEL, networkLabelForPassphrase and EXPLORER_TX_BASE_URL as the single source of truth for everything derived from STELLAR_NETWORK. Refs Parashield-Protocol#489
stellar.ts, contract.ts, WalletContext, NetworkBanner and TransactionLink each re-checked STELLAR_NETWORK === 'PUBLIC' and hard-coded passphrases / explorer URLs. They now import the shared values from lib/constants. EXPECTED_NETWORK_PASSPHRASE is kept as a re-export for existing callers. Closes Parashield-Protocol#489
|
@alansamdev 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! 🚀 |
❌ Deploy Preview for boisterous-sunshine-dd4c4c failed.
|
nonsobethel0-dev
merged commit Sep 23, 2026
700ff0e
into
Parashield-Protocol:main
0 of 5 checks passed
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
Closes #489
Closes #492
Closes #491
Closes #490
The issue points at
hooks/useStellarNetwork.tsandlib/config.ts, but neither file exists in the repo. The duplication it describes is real, though. Five modules each worked out network config fromSTELLAR_NETWORKindependently:src/lib/stellar.tsSTELLAR_NETWORK === 'PUBLIC' ? WalletNetwork.PUBLIC : …for the expected passphrasesrc/lib/contract.tsSTELLAR_NETWORK === 'PUBLIC' ? Networks.PUBLIC : Networks.TESTNETsrc/context/WalletContext.tsxnetworkLabel()andAPP_NETWORK_LABELsrc/components/NetworkBanner.tsxSTELLAR_NETWORK === 'PUBLIC'checksrc/components/TransactionLink.tsxSo there were several ways to answer "which network are we on?", and they could drift apart.
Changes
Commit 1:
src/lib/constants.tsis now the single source of truth. Added these next to the existingSTELLAR_NETWORK:IS_MAINNETNETWORK_PASSPHRASES(PUBLIC/TESTNETliterals)NETWORK_PASSPHRASE: the active network's passphraseNETWORK_LABEL:'Mainnet'/'Testnet'networkLabelForPassphrase(passphrase): a readable name for a passphrase a wallet reportsEXPLORER_TX_BASE_URLSOROBAN_RPC_URLnow usesIS_MAINNETtoo.Commit 2: consumers import the shared values instead of deriving their own.
contract.tsdrops its localNETWORK_PASSPHRASEand the unusedNetworksimport.stellar.tskeepsEXPECTED_NETWORK_PASSPHRASEas a re-export ofNETWORK_PASSPHRASE, so existing callers and the test mocks still work.WalletContext,NetworkBannerandTransactionLinkdrop their hard-coded passphrases, labels and URLs.Behaviour
No runtime change. Each derived value is the same as before on both TESTNET and PUBLIC. The passphrase literals match the SDK's
Networks.*values andWalletNetwork.*.Testing
@/lib/constants(usePolicies.test.tsanduseOracle.test.ts) only use hooks that import interval constants. They don't load the modules changed here.tscandvitesthave not been run. CI should confirm.🤖 Generated with Claude Code