Skip to content

Conversation

@tejasbadadare
Copy link
Contributor

@tejasbadadare tejasbadadare commented Sep 19, 2025

Summary

  • Add validations for Lazer price request types. This allows us to validate the input and return better error messages.
  • Add unknown_symbols to InvalidFeedSubscriptionDetails

How has this been tested?

  • Current tests cover my changes
  • Added new tests
  • Manually tested the code

@vercel
Copy link

vercel bot commented Sep 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
api-reference Ready Ready Preview Comment Sep 23, 2025 9:11pm
component-library Ready Ready Preview Comment Sep 23, 2025 9:11pm
developer-hub Ready Ready Preview Comment Sep 23, 2025 9:11pm
insights Ready Ready Preview Comment Sep 23, 2025 9:11pm
proposals Ready Ready Preview Comment Sep 23, 2025 9:11pm
staking Ready Ready Preview Comment Sep 23, 2025 9:11pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
entropy-explorer Skipped Skipped Sep 23, 2025 9:11pm

@tejasbadadare tejasbadadare marked this pull request as ready for review September 19, 2025 05:12
Copy link
Contributor

@darunrs darunrs left a 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.

Comment on lines +40 to +48
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)
}
}
Copy link
Contributor

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.

Copy link
Contributor Author

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> {
Copy link
Contributor

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?

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 don't think so, but was conforming with the existing pattern in the file :)

@tejasbadadare
Copy link
Contributor Author

tejasbadadare commented Sep 22, 2025

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.

Updated the InvalidFeedSubscriptionDetails type there thx for the reminder. I manually tested that the change is backwards compatible.

Currently the JS SDK is only focused on streaming, i'm making it more unified to handle History svc as well (future PR).

#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LatestPriceRequest {
pub struct LatestPriceRequestRepr {
Copy link
Contributor

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.

keyvankhademi
keyvankhademi previously approved these changes Sep 23, 2025
Riateche
Riateche previously approved these changes Sep 23, 2025
@tejasbadadare tejasbadadare enabled auto-merge (squash) September 23, 2025 18:44
@tejasbadadare tejasbadadare merged commit fcfa0d9 into main Sep 23, 2025
12 checks passed
@tejasbadadare tejasbadadare deleted the tb/lazer-protocol/add-missing-symbols-response-type branch September 23, 2025 21:11
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.

6 participants