feat!: allow loading network-specific PriceAccount #113
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The PriceAccount structure has diverged between Solana and Pythnet, and the SDK currently only supports loading the format stored on Solana. To support loading different kinds of price account, this PR introduces a base type
GenericPriceAccount
that can be instantiated to the two different shapes as well as being extensible to future changes to price accounts.The following steps were taken:
GenericPriceAccount
that can represent any underlying representation.PriceAccount
with an alias toGenericPriceAccount<32, ()>
for backwards compatibility.Deref
onGenericPriceAccount
so the underlying extended fields are ergonomic.SolanaPriceAccount
andPythnetPriceAccount
aliases.::account_to_feed
and::account_info_to_feed
over these types. These functions strictly speaking arePriceFeed
constructors but are implemented as conversion functions namespaced under the types.load_*
methods and re-implement the body with these new methods.CI also seems to be having trouble building with nightly so I've added toolchain files with the minimum required versions to all examples.