Skip to content

Commit

Permalink
fix: display cached image in metadata responses (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr committed Feb 9, 2023
1 parent 0ab2fbb commit 156e9e2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const Metadata = Type.Object({
name: Type.Optional(Type.String()),
description: Type.Optional(Type.String()),
image: Type.Optional(Type.String({ format: 'uri' })),
cached_image: Type.Optional(Type.String({ format: 'uri' })),
attributes: Type.Optional(Type.Array(MetadataAttribute)),
properties: Type.Optional(MetadataProperties),
localization: Type.Optional(MetadataLocalization),
Expand Down
9 changes: 5 additions & 4 deletions src/api/util/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ export function parseMetadataLocaleBundle(
if (locale && locale.metadata) {
response = {
sip: locale.metadata.sip,
name: locale.metadata.name ?? undefined,
description: locale.metadata.description ?? undefined,
image: locale.metadata.image ?? undefined,
name: locale.metadata.name,
description: locale.metadata.description,
image: locale.metadata.image,
cached_image: locale.metadata.cached_image,
};
if (locale.attributes.length > 0) {
response.attributes = locale.attributes.map(item => ({
trait_type: item.trait_type,
value: item.value as MetadataValueType,
display_type: item.display_type ?? undefined,
display_type: item.display_type,
}));
}
if (locale.properties.length > 0) {
Expand Down
6 changes: 4 additions & 2 deletions tests/ft.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ describe('FT routes', () => {
l10n_uri: null,
l10n_default: true,
description: 'test',
image: null,
cached_image: null,
image: 'http://test.com/image.png',
cached_image: 'http://test.com/image.png?processed=true',
},
attributes: [
{
Expand Down Expand Up @@ -186,6 +186,8 @@ describe('FT routes', () => {
sip: 16,
description: 'test',
name: 'hello-world',
image: 'http://test.com/image.png',
cached_image: 'http://test.com/image.png?processed=true',
attributes: [
{
display_type: 'number',
Expand Down
6 changes: 4 additions & 2 deletions tests/nft.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ describe('NFT routes', () => {
l10n_uri: null,
l10n_default: true,
description: 'test',
image: null,
cached_image: null,
image: 'http://test.com/image.png',
cached_image: 'http://test.com/image.png?processed=true',
},
attributes: [
{
Expand Down Expand Up @@ -176,6 +176,8 @@ describe('NFT routes', () => {
sip: 16,
description: 'test',
name: 'hello-world',
image: 'http://test.com/image.png',
cached_image: 'http://test.com/image.png?processed=true',
attributes: [
{
display_type: 'number',
Expand Down
6 changes: 4 additions & 2 deletions tests/sft.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ describe('SFT routes', () => {
l10n_uri: null,
l10n_default: true,
description: 'test',
image: null,
cached_image: null,
image: 'http://test.com/image.png',
cached_image: 'http://test.com/image.png?processed=true',
},
attributes: [
{
Expand Down Expand Up @@ -186,6 +186,8 @@ describe('SFT routes', () => {
sip: 16,
description: 'test',
name: 'key-alex-autoalex-v1',
image: 'http://test.com/image.png',
cached_image: 'http://test.com/image.png?processed=true',
attributes: [
{
display_type: 'number',
Expand Down

0 comments on commit 156e9e2

Please sign in to comment.