import { Provider } from "starknet" ; import { BackupWallet } from "./backup.model" ; export interface Network { id : string ; name : string ; baseUrl ? : string ; explorerUrl ? : string ; } export const networks = [ { id : "mainnet-alpha" , name : "Ethereum Mainnet" , explorerUrl : "https://voyager.online" , } , { id : "goerli-alpha" , name : "Goerli Testnet" , explorerUrl : "https://goerli.voyager.online" , } , { id : "localhost" , name : "Localhost" , } , ] ; export const defaultNetwork = networks [ 1 ] ; export const getNetwork = ( networkId ) : Network => { networkId = localNetworkId ( networkId ) ; return networks . find ( ( { id } ) => id === networkId ) || defaultNetwork ; } ; export const networkWallets = ( wallets , networkId ) => wallets . filter ( ( { network } ) => localNetworkId ( network ) === localNetworkId ( networkId ) ) ; export const localNetworkId = ( network ) => network . startsWith ( "http://localhost" ) ? "localhost" : network ; export const localNetworkUrl = ( networkId , port ) => { if ( networkId . startsWith ( "http://localhost" ) ) { return networkId ; } return networkId === "localhost" ? `http://localhost:${ port }` : networkId ; } ; export const getProvider = ( network ) => new Provider ( network . startsWith ( "http" ) ? { baseUrl : network } : { network : network as any } ) ;