-
Notifications
You must be signed in to change notification settings - Fork 307
feat(pyth-lazer-protocol): add validations for price request types, add unknown_symbols to InvalidFeedSubscriptionDetails #3065
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
feat(pyth-lazer-protocol): add validations for price request types, add unknown_symbols to InvalidFeedSubscriptionDetails #3065
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
…b/lazer-protocol/add-missing-symbols-response-type
darunrs
left a comment
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.
Can you also update the JS SDK too? I'll check your Lazer PR in a sec, but we should make sure the change is backwards compatible and also that the javascript sdk client and types work with docs updated.
| impl<'de> Deserialize<'de> for LatestPriceRequest { | ||
| fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> | ||
| where | ||
| D: serde::Deserializer<'de>, | ||
| { | ||
| let value = LatestPriceRequestRepr::deserialize(deserializer)?; | ||
| Self::new(value).map_err(Error::custom) | ||
| } | ||
| } |
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.
Is there a reason that this was manually implemented? It looks functionally very similar to the actual trait. This follows for the other trait impls below.
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.
It's handling two decoupled tasks, deserializing the input representation and applying the validation rules in LatestPriceRequest::new. It gives some type safety - once you have a PriceRequest, you know it's valid.
| } | ||
|
|
||
| impl LatestPriceRequest { | ||
| pub fn new(value: LatestPriceRequestRepr) -> Result<Self, &'static str> { |
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.
Is there a significance in the error being a static string here, instead of using anyhow Error types?
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 don't think so, but was conforming with the existing pattern in the file :)
Updated the Currently the JS SDK is only focused on streaming, i'm making it more unified to handle History svc as well (future PR). |
…b/lazer-protocol/add-missing-symbols-response-type
| #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] | ||
| #[serde(rename_all = "camelCase")] | ||
| pub struct LatestPriceRequest { | ||
| pub struct LatestPriceRequestRepr { |
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 you should increase the protocol version here too.
2d1c8a9
Summary
unknown_symbolstoInvalidFeedSubscriptionDetailsHow has this been tested?