Files
memecoin-botV2/.pnpm-store/v10/files/c8/9122dc5bc52a9a26ba65d79d609cc867a7620110228e87386566dba5c9a2efff8fb9a4d37abbce4a2c70745101d7ec7164cba364e11b3d0f403fbac7c04d93

36 lines
1.0 KiB
Plaintext

const endpoint = {
http: {
devnet: 'http://api.devnet.solana.com',
testnet: 'http://api.testnet.solana.com',
'mainnet-beta': 'http://api.mainnet-beta.solana.com/',
},
https: {
devnet: 'https://api.devnet.solana.com',
testnet: 'https://api.testnet.solana.com',
'mainnet-beta': 'https://api.mainnet-beta.solana.com/',
},
};
export type Cluster = 'devnet' | 'testnet' | 'mainnet-beta';
/**
* Retrieves the RPC API URL for the specified cluster
* @param {Cluster} [cluster="devnet"] - The cluster name of the RPC API URL to use. Possible options: 'devnet' | 'testnet' | 'mainnet-beta'
* @param {boolean} [tls="http"] - Use TLS when connecting to cluster.
*
* @returns {string} URL string of the RPC endpoint
*/
export function clusterApiUrl(cluster?: Cluster, tls?: boolean): string {
const key = tls === false ? 'http' : 'https';
if (!cluster) {
return endpoint[key]['devnet'];
}
const url = endpoint[key][cluster];
if (!url) {
throw new Error(`Unknown ${key} cluster: ${cluster}`);
}
return url;
}