-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
good first issueGood for newcomersGood for newcomers
Description
This works for now but bit of an hack.
I understand that the problem is allowing the users to switch network at runtime. We should have ENV VAR with a NETWORK _SUFFIX so we are explict about that ENV VAR to be used to wich network
The best approach is to introduce an helper to be the single source of truth around the code on how we fetch these URLs. I think it should be something like
- Network-specific env vars (e.g., VITE_ARK_SERVER_URL_BITCOIN)
- VITE_ARK_SERVER and VITE_BOLTZ_URL IF we want backward compatibility
- Local storage (user's saved config)
- Default constants (hardcoded per network, resets when network changes)
- Fail with standardized error if none found
We shoudl do this for
- ARK_SERVER_URL_
- ARK_INDEXER_URL_ (to be introduced, now SDK fallback to ARK_SERVER_URL)
- ARK_ESPLORA_URL_ (onchain provider)
- ARK_BOLTZ_URL_
interface ImportMetaEnv {
// Network-specific URL overrides
readonly VITE_ARK_SERVER_URL_BITCOIN?: string
readonly VITE_ARK_SERVER_URL_TESTNET?: string
readonly VITE_ARK_SERVER_URL_SIGNET?: string
readonly VITE_ARK_SERVER_URL_MUTINYNET?: string
readonly VITE_ARK_SERVER_URL_REGTEST?: string
readonly VITE_INDEXER_URL_BITCOIN?: string
readonly VITE_INDEXER_URL_TESTNET?: string
readonly VITE_INDEXER_URL_SIGNET?: string
readonly VITE_INDEXER_URL_MUTINYNET?: string
readonly VITE_INDEXER_URL_REGTEST?: string
readonly VITE_ESPLORA_URL_BITCOIN?: string
readonly VITE_ESPLORA_URL_TESTNET?: string
readonly VITE_ESPLORA_URL_SIGNET?: string
readonly VITE_ESPLORA_URL_MUTINYNET?: string
readonly VITE_ESPLORA_URL_REGTEST?: string
readonly VITE_BOLTZ_URL_BITCOIN?: string
readonly VITE_BOLTZ_URL_TESTNET?: string
readonly VITE_BOLTZ_URL_SIGNET?: string
readonly VITE_BOLTZ_URL_MUTINYNET?: string
readonly VITE_BOLTZ_URL_REGTEST?: string
// Add other env variables as needed
}The idea to fallback to thrown an error is that is better to tell user (I don't have all the pieces to make it work ie. ARK_SERVER_URL missing) rather than hardcoding URL we dont want to disclose in public.
tip" You can define Partial<Record> so that you dont need to have all the NetworkName to be present
export const DEFAULT_ARK_SERVER_URLS: Partial<Record<NetworkName, string>> = {
regtest: 'http://localhost:7070',
signet: 'https://signet.arkade.sh',
mutinynet: 'https://mutinynet.arkade.sh',
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomers