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

Add badges to registry #106

Merged
merged 4 commits into from
Oct 31, 2024
Merged

Add badges to registry #106

merged 4 commits into from
Oct 31, 2024

Conversation

grod220
Copy link
Contributor

@grod220 grod220 commented Oct 31, 2024

Closes: #97
Related: penumbra-zone/web#1864

Adds the badge for the osmosis chain icon to all alloyed assets coming from Osmosis.

Copy link

changeset-bot bot commented Oct 31, 2024

⚠️ No Changeset found

Latest commit: 18fe886

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Comment on lines -40 to -68
pub images: Vec<Image>,
}

#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Image {
#[serde(skip_serializing_if = "Option::is_none")]
pub png: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub svg: Option<String>,
}

impl From<Image> for AssetImage {
fn from(image: Image) -> Self {
AssetImage {
png: image.png.unwrap_or_default(),
svg: image.svg.unwrap_or_default(),
theme: None,
}
}
}

pub trait IntoPbImages {
fn into_pb_images(self) -> Vec<AssetImage>;
}

impl IntoPbImages for Vec<Image> {
fn into_pb_images(self) -> Vec<AssetImage> {
self.into_iter().map(AssetImage::from).collect()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Found defining a local image type to be unnecessary when we can just import the protobuf type directly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This chain input had an overlapping id with another input json. This means it did not render. Can delete.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

New api on the fetch-mock library w/ version bump

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Labels all the "native" alloy assets coming from osmosis with a chain badge

@grod220 grod220 requested a review from a team October 31, 2024 01:07
@grod220 grod220 self-assigned this Oct 31, 2024
Comment on lines 134 to 140
"badgesByBase": {
"transfer/channel-4/factory/osmo1em6xs47hd82806f5cxgyufguxrrc7l0aqx7nzzptjuqgswczk8csavdxek/alloyed/allUSDT": [
{
"png": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.png",
"svg": "https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/osmo.svg"
}
],
Copy link

@TalDerei TalDerei Oct 31, 2024

Choose a reason for hiding this comment

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

what if we defined a single badge entry for assets sharing the same badge?

"badges": {
  "osmosis": {
    "png": "image link",
    "svg": "image link"
  }
},
"badgesByBase": {
  "transfer/channel-4/...": ["osmosis"],
  // other channels
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good suggestion, added

.badges_by_base
.get(&metadata.base_denom().denom)
{
let mut pb_metadata: pb::Metadata = metadata.clone().into();

Choose a reason for hiding this comment

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

cloning the metadata necessary here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can't do an into() from a mutable metadata domain type

Comment on lines +13 to +16
expect(res.badges.length).toEqual(1);
expect(res.badges[0]?.png).toEqual(
'https://raw.githubusercontent.com/prax-wallet/registry/main/images/penumbra-favicon.png',
);
Copy link

@TalDerei TalDerei Oct 31, 2024

Choose a reason for hiding this comment

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

test coverage can be expanded – assets without badges and missing metadata.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Missing metadata test already there. Added test for getting asset without badge.

@grod220 grod220 merged commit 55d91b3 into main Oct 31, 2024
7 checks passed
@grod220 grod220 deleted the badges branch October 31, 2024 15:24
grod220 added a commit that referenced this pull request Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Define metadata to visually represent bridged assets
2 participants