Skip to content
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

fix(apps/hermes/server): add crypto redemption rate asset type #2112

Merged
merged 2 commits into from
Nov 13, 2024

Conversation

ali-bahjati
Copy link
Collaborator

@ali-bahjati ali-bahjati commented Nov 12, 2024

Also changes Metals to Metal to match the asset type correctly.

Copy link

vercel bot commented Nov 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
api-reference ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 13, 2024 0:23am
proposals ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 13, 2024 0:23am
staking ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 13, 2024 0:23am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
component-library ⬜️ Ignored (Inspect) Visit Preview Nov 13, 2024 0:23am
insights ⬜️ Ignored (Inspect) Visit Preview Nov 13, 2024 0:23am

Comment on lines 339 to +350
impl Display for AssetType {
fn fmt(&self, f: &mut Formatter) -> FmtResult {
write!(f, "{:?}", self)
match self {
AssetType::Crypto => write!(f, "crypto"),
AssetType::FX => write!(f, "fx"),
AssetType::Equity => write!(f, "equity"),
AssetType::Metal => write!(f, "metal"),
AssetType::Rates => write!(f, "rates"),
AssetType::CryptoRedemptionRate => write!(f, "crypto_redemption_rate"),
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe implement it using serde? It's an extra allocation but that shouldn't matter too much.

impl Display for AssetType {
    fn fmt(&self, f: &mut Formatter) -> FmtResult {
        let value = serde_json::to_value(self).unwrap();
        write!(f, "{}", value.as_str().unwrap())
    }
}

(You can also use serde_value instead of serde_json).

Copy link
Collaborator Author

@ali-bahjati ali-bahjati Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that works but i wanted to be explicit here. and being explicit here actually helped me capture a bug :D (in snake_case FX becomes f_x). I could possibly have explicit tests though but the benefit here is that if i add a new field i won't miss adding this explicit definition.

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.

3 participants