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

proto(asset): add coingecko_id to Metadata #5000

Merged
merged 3 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/core/asset/src/asset/denom_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ impl From<&Inner> for pb::Metadata {
images: inner.images.clone(),
badges: inner.badges.clone(),
priority_score: inner.priority_score,
coingecko_id: String::new(),
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions crates/proto/src/gen/penumbra.core.asset.v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ pub struct Metadata {
/// For ibc assets, usually an image of the source chain.
#[prost(message, repeated, tag = "1987")]
pub badges: ::prost::alloc::vec::Vec<AssetImage>,
/// Coingecko ID for the asset.
#[prost(string, tag = "1988")]
pub coingecko_id: ::prost::alloc::string::String,
}
impl ::prost::Name for Metadata {
const NAME: &'static str = "Metadata";
Expand Down
18 changes: 18 additions & 0 deletions crates/proto/src/gen/penumbra.core.asset.v1.serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,9 @@ impl serde::Serialize for Metadata {
if !self.badges.is_empty() {
len += 1;
}
if !self.coingecko_id.is_empty() {
len += 1;
}
let mut struct_ser = serializer.serialize_struct("penumbra.core.asset.v1.Metadata", len)?;
if !self.description.is_empty() {
struct_ser.serialize_field("description", &self.description)?;
Expand Down Expand Up @@ -1286,6 +1289,9 @@ impl serde::Serialize for Metadata {
if !self.badges.is_empty() {
struct_ser.serialize_field("badges", &self.badges)?;
}
if !self.coingecko_id.is_empty() {
struct_ser.serialize_field("coingeckoId", &self.coingecko_id)?;
}
struct_ser.end()
}
}
Expand All @@ -1309,6 +1315,8 @@ impl<'de> serde::Deserialize<'de> for Metadata {
"priority_score",
"priorityScore",
"badges",
"coingecko_id",
"coingeckoId",
];

#[allow(clippy::enum_variant_names)]
Expand All @@ -1323,6 +1331,7 @@ impl<'de> serde::Deserialize<'de> for Metadata {
Images,
PriorityScore,
Badges,
CoingeckoId,
__SkipField__,
}
impl<'de> serde::Deserialize<'de> for GeneratedField {
Expand Down Expand Up @@ -1355,6 +1364,7 @@ impl<'de> serde::Deserialize<'de> for Metadata {
"images" => Ok(GeneratedField::Images),
"priorityScore" | "priority_score" => Ok(GeneratedField::PriorityScore),
"badges" => Ok(GeneratedField::Badges),
"coingeckoId" | "coingecko_id" => Ok(GeneratedField::CoingeckoId),
_ => Ok(GeneratedField::__SkipField__),
}
}
Expand Down Expand Up @@ -1384,6 +1394,7 @@ impl<'de> serde::Deserialize<'de> for Metadata {
let mut images__ = None;
let mut priority_score__ = None;
let mut badges__ = None;
let mut coingecko_id__ = None;
while let Some(k) = map_.next_key()? {
match k {
GeneratedField::Description => {
Expand Down Expand Up @@ -1448,6 +1459,12 @@ impl<'de> serde::Deserialize<'de> for Metadata {
}
badges__ = Some(map_.next_value()?);
}
GeneratedField::CoingeckoId => {
if coingecko_id__.is_some() {
return Err(serde::de::Error::duplicate_field("coingeckoId"));
}
coingecko_id__ = Some(map_.next_value()?);
}
GeneratedField::__SkipField__ => {
let _ = map_.next_value::<serde::de::IgnoredAny>()?;
}
Expand All @@ -1464,6 +1481,7 @@ impl<'de> serde::Deserialize<'de> for Metadata {
images: images__.unwrap_or_default(),
priority_score: priority_score__.unwrap_or_default(),
badges: badges__.unwrap_or_default(),
coingecko_id: coingecko_id__.unwrap_or_default(),
})
}
}
Expand Down
Binary file modified crates/proto/src/gen/proto_descriptor.bin.no_lfs
Binary file not shown.
4 changes: 3 additions & 1 deletion proto/penumbra/penumbra/core/asset/v1/asset.proto
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ message Metadata {
// Associated icons for asset.
// For ibc assets, usually an image of the source chain.
repeated AssetImage badges = 1987;

// Coingecko ID for the asset.
string coingecko_id = 1988;
}

// DenomUnit represents a struct that describes a given denomination unit of the basic token.
Expand Down Expand Up @@ -101,7 +104,6 @@ message Balance {
repeated SignedValue values = 1;
}


// Represents a value of a known or unknown denomination.
message ValueView {
// A value whose asset ID is known and has metadata.
Expand Down
Loading