Skip to content

Commit 871551b

Browse files
authored
proto(asset): add coingecko_id to Metadata (#5000)
## Describe your changes This PR adds a field to `core.asset.v1.Metadata` to optionally augment registry asset with a `coingecko_id` ## Issue ticket number and link #4998 ## Checklist before requesting a review - [x] I have added guiding text to explain how a reviewer should test these changes. - [x] If this code contains consensus-breaking changes, I have added the "consensus-breaking" label. Otherwise, I declare my belief that there are not consensus-breaking changes, for the following reason: > Proto change
1 parent 1c01148 commit 871551b

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
lines changed

crates/core/asset/src/asset/denom_metadata.rs

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ impl From<&Inner> for pb::Metadata {
6868
images: inner.images.clone(),
6969
badges: inner.badges.clone(),
7070
priority_score: inner.priority_score,
71+
coingecko_id: String::new(),
7172
}
7273
}
7374
}

crates/proto/src/gen/penumbra.core.asset.v1.rs

+3
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ pub struct Metadata {
9999
/// For ibc assets, usually an image of the source chain.
100100
#[prost(message, repeated, tag = "1987")]
101101
pub badges: ::prost::alloc::vec::Vec<AssetImage>,
102+
/// Coingecko ID for the asset.
103+
#[prost(string, tag = "1988")]
104+
pub coingecko_id: ::prost::alloc::string::String,
102105
}
103106
impl ::prost::Name for Metadata {
104107
const NAME: &'static str = "Metadata";

crates/proto/src/gen/penumbra.core.asset.v1.serde.rs

+18
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,9 @@ impl serde::Serialize for Metadata {
12531253
if !self.badges.is_empty() {
12541254
len += 1;
12551255
}
1256+
if !self.coingecko_id.is_empty() {
1257+
len += 1;
1258+
}
12561259
let mut struct_ser = serializer.serialize_struct("penumbra.core.asset.v1.Metadata", len)?;
12571260
if !self.description.is_empty() {
12581261
struct_ser.serialize_field("description", &self.description)?;
@@ -1286,6 +1289,9 @@ impl serde::Serialize for Metadata {
12861289
if !self.badges.is_empty() {
12871290
struct_ser.serialize_field("badges", &self.badges)?;
12881291
}
1292+
if !self.coingecko_id.is_empty() {
1293+
struct_ser.serialize_field("coingeckoId", &self.coingecko_id)?;
1294+
}
12891295
struct_ser.end()
12901296
}
12911297
}
@@ -1309,6 +1315,8 @@ impl<'de> serde::Deserialize<'de> for Metadata {
13091315
"priority_score",
13101316
"priorityScore",
13111317
"badges",
1318+
"coingecko_id",
1319+
"coingeckoId",
13121320
];
13131321

13141322
#[allow(clippy::enum_variant_names)]
@@ -1323,6 +1331,7 @@ impl<'de> serde::Deserialize<'de> for Metadata {
13231331
Images,
13241332
PriorityScore,
13251333
Badges,
1334+
CoingeckoId,
13261335
__SkipField__,
13271336
}
13281337
impl<'de> serde::Deserialize<'de> for GeneratedField {
@@ -1355,6 +1364,7 @@ impl<'de> serde::Deserialize<'de> for Metadata {
13551364
"images" => Ok(GeneratedField::Images),
13561365
"priorityScore" | "priority_score" => Ok(GeneratedField::PriorityScore),
13571366
"badges" => Ok(GeneratedField::Badges),
1367+
"coingeckoId" | "coingecko_id" => Ok(GeneratedField::CoingeckoId),
13581368
_ => Ok(GeneratedField::__SkipField__),
13591369
}
13601370
}
@@ -1384,6 +1394,7 @@ impl<'de> serde::Deserialize<'de> for Metadata {
13841394
let mut images__ = None;
13851395
let mut priority_score__ = None;
13861396
let mut badges__ = None;
1397+
let mut coingecko_id__ = None;
13871398
while let Some(k) = map_.next_key()? {
13881399
match k {
13891400
GeneratedField::Description => {
@@ -1448,6 +1459,12 @@ impl<'de> serde::Deserialize<'de> for Metadata {
14481459
}
14491460
badges__ = Some(map_.next_value()?);
14501461
}
1462+
GeneratedField::CoingeckoId => {
1463+
if coingecko_id__.is_some() {
1464+
return Err(serde::de::Error::duplicate_field("coingeckoId"));
1465+
}
1466+
coingecko_id__ = Some(map_.next_value()?);
1467+
}
14511468
GeneratedField::__SkipField__ => {
14521469
let _ = map_.next_value::<serde::de::IgnoredAny>()?;
14531470
}
@@ -1464,6 +1481,7 @@ impl<'de> serde::Deserialize<'de> for Metadata {
14641481
images: images__.unwrap_or_default(),
14651482
priority_score: priority_score__.unwrap_or_default(),
14661483
badges: badges__.unwrap_or_default(),
1484+
coingecko_id: coingecko_id__.unwrap_or_default(),
14671485
})
14681486
}
14691487
}
Binary file not shown.

proto/penumbra/penumbra/core/asset/v1/asset.proto

+3-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ message Metadata {
7171
// Associated icons for asset.
7272
// For ibc assets, usually an image of the source chain.
7373
repeated AssetImage badges = 1987;
74+
75+
// Coingecko ID for the asset.
76+
string coingecko_id = 1988;
7477
}
7578

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

104-
105107
// Represents a value of a known or unknown denomination.
106108
message ValueView {
107109
// A value whose asset ID is known and has metadata.

0 commit comments

Comments
 (0)