diff --git a/src/mappings/multiTokens/events/attribute_removed.ts b/src/mappings/multiTokens/events/attribute_removed.ts index 82cf1a8b0..7d9a0f698 100644 --- a/src/mappings/multiTokens/events/attribute_removed.ts +++ b/src/mappings/multiTokens/events/attribute_removed.ts @@ -6,6 +6,7 @@ import { Attribute, Collection, Event as EventModel, Extrinsic, MultiTokensAttri import { Event } from '../../../types/generated/support' import { CommonContext } from '../../types/contexts' import { processMetadata } from '../../../jobs/process-metadata' +import { computeTraits } from '../../../jobs/compute-traits' interface EventData { collectionId: bigint @@ -69,6 +70,7 @@ export async function attributeRemoved( token.attributeCount -= 1 await ctx.store.save(token) processMetadata(token.id, 'token', true) + computeTraits(data.collectionId.toString()) } else if (attribute.collection) { const collection = await ctx.store.findOneOrFail(Collection, { where: { id: data.collectionId.toString() }, diff --git a/src/mappings/multiTokens/events/attribute_set.ts b/src/mappings/multiTokens/events/attribute_set.ts index 7364c7482..b72fe9c26 100644 --- a/src/mappings/multiTokens/events/attribute_set.ts +++ b/src/mappings/multiTokens/events/attribute_set.ts @@ -167,7 +167,7 @@ export async function attributeSet( processMetadata(collection.id, 'collection', true) } } - if (token && token.metadata?.attributes) { + if (token) { computeTraits(collection.id) } diff --git a/src/mappings/multiTokens/events/burned.ts b/src/mappings/multiTokens/events/burned.ts index d728212b0..2d6c32223 100644 --- a/src/mappings/multiTokens/events/burned.ts +++ b/src/mappings/multiTokens/events/burned.ts @@ -103,11 +103,8 @@ export async function burned( if (token) { token.supply -= data.amount - - if (token.metadata?.attributes) { - computeTraits(data.collectionId.toString()) - } - ctx.store.save(token) + computeTraits(data.collectionId.toString()) + await ctx.store.save(token) syncCollectionStats(data.collectionId.toString()) } diff --git a/src/mappings/multiTokens/events/minted.ts b/src/mappings/multiTokens/events/minted.ts index 5651bcb10..3149078a8 100644 --- a/src/mappings/multiTokens/events/minted.ts +++ b/src/mappings/multiTokens/events/minted.ts @@ -99,7 +99,7 @@ export async function minted( where: { id: `${u8aToHex(data.recipient)}-${data.collectionId}-${data.tokenId}` }, }) - if (token.supply !== 0n && token.metadata?.attributes) { + if (token.metadata?.attributes) { computeTraits(data.collectionId.toString()) }