Phase 1: Shared config centralization#10
Conversation
Created client/src/lib/config.ts: - Single source of truth for chain IDs, contract addresses, chain metadata - SUPPORTED_CHAIN_IDS, SupportedChainId type - CHAINS record with Base (8453) and PulseChain (369) metadata - Helper functions: getChainConfig, getHeroAddress, getStakingAddress, getExplorer, etc. - Backward compat exports: HERO_ADDRESSES, STAKING_ADDRESSES, CHAIN_IDS Created client/src/lib/external-links.ts: - Explorer links: getExplorerAddressUrl, getExplorerTxUrl, getExplorerTokenUrl - DEX/swap links: getSwapUrl, getLiquidityUrl - Bridge links: getBridgeUrl - External links: documentation, discord, twitter, telegram, github, website Verified addresses from existing repo sources. Build: pnpm build passes (24.36s) Tests: 240/260 pass (20 require VITE_WALLETCONNECT_PROJECT_ID)
useStaking.ts: - Removed duplicate STAKING_ADDRESSES record - Now imports getStakingAddress() from shared config - Kept HERO_STAKING_ADDRESS export for backward compat HeroStake.tsx: - Replaced duplicate CHAIN_CONFIG with getHeroStakeChainConfig() - Uses shared getChainConfig() for heroCA and explorer - Only keeps local display config (name, color) config.ts: - Fixed staking addresses from useStaking.ts (Base: 0xAD79..., Pulse: 0xD5F1...) Scanner (check-token-registry.mjs): - Created to detect duplicated hardcoded addresses - Reports 33 violations in other files (Phase 2 scope) Build: passes (23.80s)
pnpm upgrade: - packageManager: 10.25.0 → 10.27.0 (fixes critical/high CVEs) Migrated to shared config: - Dashboard.tsx: Removed HERO_ADDRESS, VETS_ADDRESS; uses getHeroAddress(), getVETSAddress() - HeroWallet.tsx: BALANCE_CHAINS now uses getHeroAddress() and getRPCs() - HeroSwapWidget.tsx: buildDEXLinks() uses getHeroAddress() for dynamic URLs - config.ts: Added getVETSAddress() helper Scanner violations reduced: 33 → 28 Remaining violations: Dashboard (VETS), HeroWallet (VETS), AppLayout, Swap, etc. Build: passes (23.57s)
Migrated to shared config: - Swap.tsx: Uses getHeroAddress(369) for Switch.win and SquirrelSwap URLs - SquirrelSwapWidget.tsx: buildDEXLinks-like pattern uses getHeroAddress() - PortfolioDashboard.tsx: CONTRACTS.hero now uses getHeroAddress() - HeroSwapWidget.tsx: Fixed undefined check with fallback address Scanner violations reduced: 28 → 25 (remaining in Phase 2 scope: AppLayout, LiveTicker, PortfolioPnL, etc.) Build: passes (23.49s)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dcb6639d5e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| {/* CTA Button */} | ||
| <a | ||
| href="https://switch.win/?network=pulsechain&to=0x35a51Dfc82032682E4Bda8AAcA87B9Bc386C3D27" | ||
| href="https://switch.win/?network=pulsechain&to={`${heroPulse}`}" |
There was a problem hiding this comment.
Interpolate HERO address in swap CTA URLs
When users click the Swap page CTAs, this string literal sends the to parameter as the literal text `${heroPulse}` instead of the PulseChain HERO contract address; the SquirrelSwap link below has the same pattern for tokenOut. As a result these aggregators cannot preselect HERO from the Swap page, regressing the main buy flow that previously passed the hardcoded token address.
Useful? React with 👍 / 👎.
Summary
This is a foundational shared-config PR, not a production deployment PR.
Creates and begins adoption of shared configuration for HeroBase token, chain, staking, RPC, and external-link data.
What this PR does
config.ts(+140 lines): Single source of truth for:CHAINS- Base (8453) and PulseChain (369) chain configsHERO_ADDRESSES- HERO token contract addresses per chainSTAKING_ADDRESSES- Staking contract addresses per chainVETS_ADDRESS- VETS token on PulseChaingetChainConfig(),getHeroAddress(),getStakingAddress(),getVETSAddress(),getRPCs(),getTokenBySymbol()external-links.ts(+107 lines): External URLs for explorers, bridges, DEXes, documentation8 files migrated to use shared config:
useStaking.ts,HeroStake.tsx,Dashboard.tsx,HeroWallet.tsxHeroSwapWidget.tsx,SquirrelSwapWidget.tsx,Swap.tsx,PortfolioDashboard.tsxscripts/check-token-registry.mjs: Scanner to detect duplicated hardcoded addressesResults
Known Risks
VITE_WALLETCONNECT_PROJECT_IDin CI)Commands
pnpm buildpnpm testpnpm checkpnpm auditRecommendation
Ready to merge as foundation only. Not safe for production deploy.
This PR creates the shared config scaffolding. Remaining work tracked below.
Follow-up Tasks
VITE_WALLETCONNECT_PROJECT_IDin GitHub Actions