Skip to content

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

Merged
merged 6 commits into from
Sep 13, 2022
Merged

Conversation

jayantk
Copy link
Contributor

@jayantk jayantk commented Sep 12, 2022

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.

@@ -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'
Copy link
Contributor Author

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.

@cctdaniel
Copy link
Contributor

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.

just for curiosity isn't pyth-monkey built using python?

Comment on lines +11 to +14
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;
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@cctdaniel
Copy link
Contributor

cctdaniel commented Sep 13, 2022

@ali-bahjati could you help to review since I pushed a commit and can't approve 😅 but lgtm generally

cctdaniel
cctdaniel previously approved these changes Sep 13, 2022
@jayantk jayantk merged commit 6821430 into main Sep 13, 2022
@jayantk jayantk deleted the more_fields branch September 13, 2022 03:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants