1
- import { Cluster , PublicKey } from '@solana/web3.js'
1
+ import { Cluster , clusterApiUrl , PublicKey } from '@solana/web3.js'
2
+
3
+ export type PythCluster = Cluster | 'pythtest'
2
4
3
5
/** Mapping from solana clusters to the public key of the pyth program. */
4
- const clusterToPythProgramKey : Record < Cluster , string > = {
6
+ const clusterToPythProgramKey : Record < PythCluster , string > = {
5
7
'mainnet-beta' : 'FsJ3A3u2vn5cTVofAjvy6y5kwABJAqYWpe4975bi2epH' ,
6
8
devnet : 'gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s' ,
7
9
testnet : '8tfDNiaEyrV6Q1U4DEXrEigs9DoDtkugzFbybENEbCDz' ,
10
+ pythtest : '8tfDNiaEyrV6Q1U4DEXrEigs9DoDtkugzFbybENEbCDz' ,
8
11
}
9
12
10
13
/** Gets the public key of the Pyth program running on the given cluster. */
11
- export function getPythProgramKeyForCluster ( cluster : Cluster ) : PublicKey {
14
+ export function getPythProgramKeyForCluster ( cluster : PythCluster ) : PublicKey {
12
15
if ( clusterToPythProgramKey [ cluster ] !== undefined ) {
13
16
return new PublicKey ( clusterToPythProgramKey [ cluster ] )
14
17
} else {
@@ -19,3 +22,13 @@ export function getPythProgramKeyForCluster(cluster: Cluster): PublicKey {
19
22
)
20
23
}
21
24
}
25
+
26
+ /** Retrieves the RPC API URL for the specified Pyth cluster */
27
+ export function getPythClusterApiUrl ( cluster : PythCluster ) : string {
28
+ // TODO: Add pythnet when it's ready
29
+ if ( cluster === 'pythtest' ) {
30
+ return 'https://api.pythtest.pyth.network'
31
+ } else {
32
+ return clusterApiUrl ( cluster )
33
+ }
34
+ }
0 commit comments