fix: add testnetChannelEndpoint()
This commit is contained in:
27
web3.js/src/util/testnet.js
Normal file
27
web3.js/src/util/testnet.js
Normal file
@@ -0,0 +1,27 @@
|
||||
//@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}`);
|
||||
}
|
Reference in New Issue
Block a user