solana/web3.js/src/util/testnet.js
2020-06-14 21:57:04 -07:00

28 lines
583 B
JavaScript

//@flow
import {testnetDefaultChannel} from '../../package.json';
/**
* @private
*/
const endpoint = {
edge: 'https://api.edge.testnet.solana.com',
beta: 'https://api.beta.testnet.solana.com',
stable: 'https://api.testnet.solana.com',
};
/**
* Retrieves the RPC endpoint URL for the specified testnet release
* channel
*/
export function testnetChannelEndpoint(channel?: string): string {
if (!channel) {
return endpoint[testnetDefaultChannel];
}
if (endpoint[channel]) {
return endpoint[channel];
}
throw new Error(`Unknown channel: ${channel}`);
}