-
Notifications
You must be signed in to change notification settings - Fork 218
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Skipped Deployments
|
124a271
to
4c8665d
Compare
4c8665d
to
438e559
Compare
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"), | ||
} | ||
} | ||
} |
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.
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).
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.
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.
Also changes Metals to Metal to match the asset type correctly.