forked from solana-labs/example-token
-
Notifications
You must be signed in to change notification settings - Fork 0
/
url.js
31 lines (25 loc) · 942 Bytes
/
url.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// To connect to a public cluster, set `export LIVE=1` in your
// environment. By default, `LIVE=1` will connect to the devnet cluster.
import {clusterApiUrl, Cluster} from '@solana/web3.js';
import dotenv from 'dotenv';
function chooseCluster(): Cluster | undefined {
dotenv.config();
if (!process.env.LIVE) return;
switch (process.env.CLUSTER) {
case 'devnet':
case 'testnet':
case 'mainnet-beta': {
return process.env.CLUSTER;
}
}
throw 'Unknown cluster "' + process.env.CLUSTER + '", check the .env file';
}
export const cluster = chooseCluster();
export const url =
process.env.RPC_URL ||
(process.env.LIVE ? clusterApiUrl(cluster, false) : 'http://localhost:8899');
export const urlTls =
process.env.RPC_URL ||
(process.env.LIVE ? clusterApiUrl(cluster, true) : 'http://localhost:8899');
export let walletUrl =
process.env.WALLET_URL || 'https://solana-example-webwallet.herokuapp.com/';