Skip to content

Commit

Permalink
hot: fixes computeTraits calls (#693)
Browse files Browse the repository at this point in the history
  • Loading branch information
justraman authored Oct 27, 2023
1 parent 3f34ed3 commit 3042513
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/mappings/multiTokens/events/attribute_removed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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>(Collection, {
where: { id: data.collectionId.toString() },
Expand Down
2 changes: 1 addition & 1 deletion src/mappings/multiTokens/events/attribute_set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ export async function attributeSet(
processMetadata(collection.id, 'collection', true)
}
}
if (token && token.metadata?.attributes) {
if (token) {
computeTraits(collection.id)
}

Expand Down
7 changes: 2 additions & 5 deletions src/mappings/multiTokens/events/burned.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

Expand Down
2 changes: 1 addition & 1 deletion src/mappings/multiTokens/events/minted.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

Expand Down

0 comments on commit 3042513

Please sign in to comment.