From 69735467d05b5b275a03c5d0c12d0aebf935e689 Mon Sep 17 00:00:00 2001 From: Leonardo Custodio Date: Wed, 13 Dec 2023 02:02:57 -0300 Subject: [PATCH] Update token_created.ts (#755) Co-authored-by: Raman Shekhawat --- .../multiTokens/events/token_created.ts | 31 +------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/src/mappings/multiTokens/events/token_created.ts b/src/mappings/multiTokens/events/token_created.ts index 4f8dffca..1a966555 100644 --- a/src/mappings/multiTokens/events/token_created.ts +++ b/src/mappings/multiTokens/events/token_created.ts @@ -1,17 +1,14 @@ import { SubstrateBlock } from '@subsquid/substrate-processor' import { EventItem } from '@subsquid/substrate-processor/lib/interfaces/dataSelection' import { u8aToHex } from '@polkadot/util' -import { IsNull } from 'typeorm' import { UnknownVersionError } from '../../../common/errors' import { MultiTokensTokenCreatedEvent } from '../../../types/generated/events' import { - Attribute, CapType, Collection, Event as EventModel, Extrinsic, FreezeState, - Metadata, MultiTokensTokenCreated, Royalty, Token, @@ -781,41 +778,15 @@ export async function tokenCreated( } if (item.event.call) { - const [callData, collection, collectionUri] = await Promise.all([ + const [callData, collection] = await Promise.all([ getCallData(ctx, item.event.call, eventData), ctx.store.findOneOrFail(Collection, { where: { id: eventData.collectionId.toString() }, }), - ctx.store.findOne(Attribute, { - where: { key: 'uri', token: IsNull(), collection: { id: eventData.collectionId.toString() } }, - }), ]) if (!eventData || !callData) return undefined - // TODO: Far from ideal but we will do this only until we don't have the metadata processor - let metadata: Metadata | null | undefined = null - if (collectionUri && (collectionUri.value.includes('{id}.json') || collectionUri.value.includes('%7Bid%7D.json'))) { - metadata = await new Metadata() - if (metadata) { - const collectionWithTokens = await ctx.store.findOneOrFail(Collection, { - where: { id: eventData.collectionId.toString() }, - relations: { - tokens: true, - }, - }) - - const otherTokens: Token[] = collectionWithTokens.tokens.map((e) => { - e.metadata = metadata - return e - }) - - if (otherTokens.length > 0) { - ctx.store.save(otherTokens) - } - } - } - const token = new Token({ id: `${eventData.collectionId}-${eventData.tokenId}`, tokenId: eventData.tokenId,