-
Notifications
You must be signed in to change notification settings - Fork 44
Add a verbose callback with access to solana account data #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -3,12 +3,15 @@ import { PythConnection } from './PythConnection' | |||
import { getPythClusterApiUrl, getPythProgramKeyForCluster, PythCluster } from './cluster' | |||
import { PriceStatus } from '.' | |||
|
|||
const SOLANA_CLUSTER_NAME: PythCluster = 'mainnet-beta' | |||
const SOLANA_CLUSTER_NAME: PythCluster = 'devnet' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drive-by: this example fails when pointed to mainnet because the default solana mainnet RPC endpoint no longer accepts program subscribe calls.
just for curiosity isn't pyth-monkey built using python? |
pythConnection.onPriceChangeVerbose((productAccount, priceAccount) => { | ||
// The arguments to the callback include solana account information / the update slot if you need it. | ||
const product = productAccount.accountInfo.data.product; | ||
const price = priceAccount.accountInfo.data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we also wanna keep the onPriceChange
example or do we want to encourage new users to use onPriceChangeVerbose
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think most people will prefer the verbose function (because you almost always need the account keys), hence why i used that in the example.
@ali-bahjati could you help to review since I pushed a commit and can't approve 😅 but lgtm generally |
I'm trying to use this library to build a dashboard in pyth-monkey and I need access to the account keys / slots of updates. I've run into this problem before so I figured it's worth adding to the API.
This change adds a new kind of callback to the connection API that gives you all of the associated solana metadata in addition to the content of the account. I did this via a new function / callback type in order to maintain backward compatibility.