Skip to content

Conversation

@davedumto
Copy link

Add Network Picker for Unified Deployment

closes #247

Problem

Previously, we had 2 separate deployments (testnet and mainnet) which created maintenance overhead and limited our ability to test UI changes across networks efficiently. Users couldn't easily switch between networks without separate deployment URLs.

Solution

Implemented a unified deployment approach with runtime network selection:

🎯 Key Changes

  • Network Picker Component: Added dropdown in navbar for switching between testnet/mainnet
  • Centralized Configuration: Created utils/networks.ts for all network settings
  • Dynamic Service Creation: All services (wallet kit, domain SDK, tansu client) now use current network config
  • CORS Fix: Added development proxy for mainnet RPC endpoints
  • Footer Integration: Stellar Explorer links now update based on selected network

🔧 Technical Implementation

  1. NetworkPicker Component (src/components/page/network/NetworkPicker.tsx)

    • Clean dropdown with network status indicators
    • Visual feedback (green dot for mainnet, yellow for testnet)
    • Click-outside-to-close functionality
  2. Network Configuration (src/utils/networks.ts)

    • Testnet and mainnet settings in one place
    • LocalStorage persistence for user choice
    • Helper functions for getting current network config
  3. Service Updates

    • stellar-wallets-kit.ts: Dynamic wallet configuration
    • soroban_domain_sdk.ts: Network-aware domain SDK
    • soroban_tansu.ts: Dynamic contract client creation
  4. Development Proxy (astro.config.mjs)

    • Solves CORS issues with mainnet RPC endpoints
    • Allows x-client-name header from Stellar SDK

🎨 UI/UX Features

  • Network status indicators (Live/Test badges)
  • Hover states and smooth transitions
  • Accessible dropdown with proper focus management
  • Integrated seamlessly into existing navbar layout

✅ Benefits

  • Single Deployment: Easier maintenance and CI/CD
  • Full Flexibility: Users can test both networks in same UI
  • Better DX: Developers can switch networks without environment changes
  • Future-Proof: Easy to add more networks if needed

🧪 Testing

  • Switching networks reloads page with new configuration
  • All contract calls use selected network
  • Stellar Explorer links update correctly
  • LocalStorage preserves user's network choice

##Video

Screen.Recording.2025-09-30.at.23.55.36.mov

@netlify
Copy link

netlify bot commented Sep 30, 2025

Deploy Preview for tansu canceled.

Name Link
🔨 Latest commit f71bec1
🔍 Latest deploy log https://app.netlify.com/projects/tansu/deploys/68de67d0c44fcf0008485418

@netlify
Copy link

netlify bot commented Sep 30, 2025

Deploy Preview for staging-tansu ready!

Name Link
🔨 Latest commit f71bec1
🔍 Latest deploy log https://app.netlify.com/projects/staging-tansu/deploys/68de67d0e51dcf0008694348
😎 Deploy Preview https://deploy-preview-276--staging-tansu.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 62
Accessibility: 89
Best Practices: 83
SEO: 92
PWA: 80
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

- Resolved conflict in Navbar.astro to include NetworkPicker
- Updated with latest responsive modal and other improvements from main
Copy link
Owner

@tupui tupui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some review

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems unrelated no?

Copy link
Owner

@tupui tupui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Starting to look good. A couple of things.

The buttons are now joined which should not be the case.
Image

The background should be with a blur as we have elsewhere when a modal opens.
Image

I tried to do an operation with a xBull wallet on testnet and got this.
Image

Comment on lines 38 to 48
export function getNetworkByName(network: NetworkName) {
return networks[network];
}

export function getNetworkConfig() {
return networks[getCurrentNetwork()];
}

export function getNetwork(network: NetworkName) {
return networks[network];
} No newline at end of file
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need 3 functions doing the same thing.

const config = getNetworkConfig();
const defaultFee = "100";
const defaultTimeout = 30;
const simulationAccount = "GCMFQP44AR32S7IRIUKNOEJW5PNWOCLRHLQWSHUCSV4QZOMUXZOVA7Q2"; // From tansu.toml
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why changing from import.meta.env.PUBLIC_TANSU_OWNER_ID? We need this address. This is helpful for fees, etc.

Comment on lines +15 to +16
tansu_contract: import.meta.env.PUBLIC_TANSU_CONTRACT_ID,
domain_contract: import.meta.env.PUBLIC_SOROBAN_DOMAIN_CONTRACT_ID,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to make new env variables for these otherwise that does not make sense. Contracts have diff addresses on mainnet and testnet.

return createWalletKit();
}

export const kit = getKit();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really dynamic then?

Copy link
Owner

@tupui tupui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made another pass. Please answer the conversations as well. Let me close the threads myself.

@tupui
Copy link
Owner

tupui commented Nov 30, 2025

Hey @davedumto do you want to continue?

@davedumto
Copy link
Author

davedumto commented Dec 1, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Revisit testnet vs mainnet deployment

2 participants