-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jayant Krishnamurthy
committed
Nov 10, 2021
1 parent
c795a1f
commit 32b9e69
Showing
6 changed files
with
38 additions
and
26 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
import {Cluster, PublicKey} from '@solana/web3.js' | ||
import { Cluster, PublicKey } from '@solana/web3.js' | ||
|
||
/** Mapping from solana clusters to the public key of the pyth program. */ | ||
const clusterToPythProgramKey: Record<Cluster, string> = { | ||
'mainnet-beta': 'FsJ3A3u2vn5cTVofAjvy6y5kwABJAqYWpe4975bi2epH', | ||
'devnet': 'gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s', | ||
'testnet': '8tfDNiaEyrV6Q1U4DEXrEigs9DoDtkugzFbybENEbCDz', | ||
devnet: 'gSbePebfvPy7tRqimPoVecS2UsBvYv46ynrzWocc92s', | ||
testnet: '8tfDNiaEyrV6Q1U4DEXrEigs9DoDtkugzFbybENEbCDz', | ||
} | ||
|
||
/** Gets the public key of the Pyth program running on the given cluster. */ | ||
export function getPythProgramKeyForCluster(cluster: Cluster): PublicKey { | ||
if (clusterToPythProgramKey[cluster] !== undefined) { | ||
return new PublicKey(clusterToPythProgramKey[cluster]); | ||
return new PublicKey(clusterToPythProgramKey[cluster]) | ||
} else { | ||
throw new Error(`Invalid Solana cluster name: ${cluster}. Valid options are: ${JSON.stringify(Object.keys(clusterToPythProgramKey))}`) | ||
throw new Error( | ||
`Invalid Solana cluster name: ${cluster}. Valid options are: ${JSON.stringify( | ||
Object.keys(clusterToPythProgramKey), | ||
)}`, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters