feat(network): mainnet RPC + settings switcher (Tier 3.1)#3
Closed
epicexcelsior wants to merge 3 commits into
Closed
feat(network): mainnet RPC + settings switcher (Tier 3.1)#3epicexcelsior wants to merge 3 commits into
epicexcelsior wants to merge 3 commits into
Conversation
Adds a Settings → Network row that opens a bottom-sheet for picking
mainnet beta / devnet / custom RPC. Choice persists to AsyncStorage and
takes priority over the build-time EXPO_PUBLIC_SOLANA_RPC default.
- src/infrastructure/network/preference.ts: pref types, layered URL
resolution (pref → env → public devnet), cached load + change emitter
- src/infrastructure/network/connection.ts: getEffectiveRpcUrl() +
getActiveSolanaConnection(); singleton rebuilt on every pref change,
legacy solanaConnection export kept for back-compat
- context/NetworkModeContext.tsx: exposes pref / cluster / rpcUrl /
setPref; rebuilds DirectRpcAdapter when pref.url changes so live
consumers (balance / send) pick up the new endpoint without restart
- components/settings/NetworkSwitcherSheet.tsx: radio selection +
validated custom URL input; mainnet selection gated behind a one-time
confirmation alert ("real funds, not audited"), acknowledgement
persisted in PrefKeys.MAINNET_ACK
- screens/SettingsScreen.tsx: new "solana cluster · {current}" row above
cellular fallback in the existing network section
- src/storage/index.ts: NETWORK_PREF + MAINNET_ACK key constants
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Explorer URLs were hardcoded to ?cluster=devnet, so a transaction sent on mainnet would open as if it were a devnet tx and report "not found". Now reads the active cluster via getEffectiveCluster() — mainnet drops the query (explorer.solana.com default), devnet/testnet/custom map to their documented values. Custom RPCs fall back to devnet for display since the explorer can't resolve a private endpoint on its own. Function name preserved for back-compat with existing callsites (TxDetailModal, SuccessCard, FailureCard, sendTransaction); also adds a clearer buildExplorerTxUrl alias for new callers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Surfaces an additional warning banner inside ExportWalletModal when the runtime cluster is mainnet beta. Sits above the existing recovery-key warning so a user who graduated onto mainnet via the network switcher gets a clear "these keys move real funds" prompt before they see the secret. T-WALLET-* threat-model family. Non-mainnet (devnet/testnet/custom) flow is unchanged. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Owner
Author
|
Re-routing to anonmesh/mobile_app — wrong repo target by mistake. |
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
EXPO_PUBLIC_SOLANA_RPCenv default.PrefKeys.MAINNET_ACK.?cluster=query (the explorer default), devnet/testnet/custom map correctly, fixing the previous always-?cluster=devnethardcode.Files
src/infrastructure/network/preference.ts(new): pref types, layered URL resolution (pref → env → public devnet), cached load + change emitter, mainnet/devnet/testnet defaults, URL validator.src/infrastructure/network/connection.ts: addsgetEffectiveRpcUrl()/getActiveSolanaConnection(); singleton rebuilt on every pref change via subscriber. LegacysolanaConnectionexport kept for back-compat.context/NetworkModeContext.tsx: exposespref/cluster/rpcUrl/setPref; rebuildsDirectRpcAdapterwhenpref.urlchanges so live consumers (balance / send) pick up the new endpoint without restart.components/settings/NetworkSwitcherSheet.tsx(new): radio selection + validated custom URL input, mainnet confirmation gate, active-URL preview.components/settings/ExportWalletModal.tsx: mainnet-only banner above the recovery-key warning.screens/SettingsScreen.tsx: new "solana cluster · {current}" row in the network section.src/services/explorer.ts: cluster-aware URL builder.src/storage/index.ts:NETWORK_PREF+MAINNET_ACKkey constants.Singleton rebuild — full / restart-required / not-attempted
Full. The
solanaConnectionexport is reassigned in-place on every pref change (subscribed module-side), anduseNetworkMode()'sDirectRpcAdapterre-mounts onpref.urlchange, so the live UI paths (balance refresh, send transaction blockhash / submit) follow the new endpoint without restart. A restart hint remains in the sheet UI as belt-and-suspenders for any caller that captured the connection at module-load and never re-reads it.Coordination with anonmesh#52 (NetworkBanner)
Banner was NOT extended in this PR — it doesn't exist on this branch yet. PR anonmesh#52 ships the env-only banner; a follow-up after both merge will extend it to read the runtime pref via
useNetworkMode().cluster. Merge order: anonmesh#52 first, then this PR.Safety rails respected
MeshRpcAdapterrouting untouched (fix(send): off-grid resilience — timeouts, render-time gate, adapter-race log anonmesh/mobile_app#53's territory)sendTransactionsend flow untouched (fix(send): off-grid resilience — timeouts, render-time gate, adapter-race log anonmesh/mobile_app#53's territory)LOCAL_NOTES/editsTest plan
?cluster=devnet)Generated with Claude Code.