Skip to content

Commit

Permalink
hot: fixes metadata issue (#550)
Browse files Browse the repository at this point in the history
hot fixes metada issue
  • Loading branch information
justraman authored Aug 9, 2023
1 parent 9b0ba12 commit a886a6d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/populateGenesis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ async function syncAttributes(ctx: CommonContext, block: SubstrateBlock) {
updatedAt: new Date(block.timestamp),
})

if (key === 'uri') {
if (['uri', 'name', 'description', 'fallback_image', 'media', 'attributes'].includes(key)) {
const token = new Token({ id, metadata: new Metadata() })
token.metadata = await getMetadata(token.metadata as Metadata, attribute)
await ctx.store.save(token)
Expand All @@ -420,7 +420,7 @@ async function syncAttributes(ctx: CommonContext, block: SubstrateBlock) {
updatedAt: new Date(block.timestamp),
})

if (key === 'uri') {
if (['uri', 'name', 'description', 'fallback_image', 'media', 'attributes'].includes(key)) {
const collection = new Collection({ id, metadata: new Metadata() })
collection.metadata = await getMetadata(collection.metadata as Metadata, attribute)
await ctx.store.save(collection)
Expand Down
9 changes: 9 additions & 0 deletions src/server-extension/resolvers/refresh_metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ export class RefreshMetadataResolver {
resource.metadata = new Metadata()
}
resource.metadata = await getMetadata(resource.metadata, resource.attributes.find((a) => a.key === 'uri') ?? null)
const syncAttributesPromise = resource.attributes
.filter((a) => a.key !== 'uri')
.map(async (a) => {
if (resource && resource.metadata) {
resource.metadata = await getMetadata(resource.metadata, a)
}
})

await Promise.all(syncAttributesPromise)
try {
await manager.save(resource)
} catch (error) {
Expand Down

0 comments on commit a886a6d

Please sign in to comment.