diff --git a/src/modules/assets/models/AuctionEvent.enum.ts b/src/modules/assets/models/AuctionEvent.enum.ts index 139b5c4bd..ddb7ad3ca 100644 --- a/src/modules/assets/models/AuctionEvent.enum.ts +++ b/src/modules/assets/models/AuctionEvent.enum.ts @@ -49,6 +49,9 @@ export enum NftEventEnum { ESDTNFTCreate = 'ESDTNFTCreate', ESDTNFTBurn = 'ESDTNFTBurn', ESDTNFTUpdateAttributes = 'ESDTNFTUpdateAttributes', + ESDTMetaDataUpdate = 'ESDTMetaDataUpdate', + ESDTMetaDataRecreate = 'ESDTMetaDataRecreate', + ESDTModifyCreator = 'ESDTModifyCreator', } export enum NftEventTypeEnum { diff --git a/src/modules/rabbitmq/blockchain-events/nft-events.service.ts b/src/modules/rabbitmq/blockchain-events/nft-events.service.ts index 58d0b05eb..2ec6cb1a3 100644 --- a/src/modules/rabbitmq/blockchain-events/nft-events.service.ts +++ b/src/modules/rabbitmq/blockchain-events/nft-events.service.ts @@ -7,6 +7,7 @@ import { MintEvent } from '../entities/auction/mint.event'; import { MultiTransferEvent, TransferEvent } from '../entities/auction/transfer.event'; import { FeedEventsSenderService } from './feed-events.service'; import { BurnEvent } from '../entities/auction/burn.event'; +import { UpdateAttributesEvent } from '../entities/auction/update-attributes.event'; @Injectable() export class NftEventsService { @@ -14,7 +15,7 @@ export class NftEventsService { private feedEventsSenderService: FeedEventsSenderService, private mxApiService: MxApiService, private readonly cacheEventsPublisherService: CacheEventsPublisherService, - ) {} + ) { } public async handleNftMintEvents(mintEvents: any[], hash: string) { for (let event of mintEvents) { @@ -71,8 +72,23 @@ export class NftEventsService { } } } + break; + case NftEventEnum.ESDTModifyCreator: + case NftEventEnum.ESDTMetaDataRecreate: + case NftEventEnum.ESDTMetaDataUpdate: + case NftEventEnum.ESDTNFTUpdateAttributes: + const updateEvent = new UpdateAttributesEvent(event); + const updateTopics = updateEvent.getTopics(); + const collectionUpdateInfo = await this.mxApiService.getCollectionByIdentifierForQuery(updateTopics.collection, 'fields=name,type'); + if (collectionUpdateInfo?.type === NftTypeEnum.NonFungibleESDT || collectionUpdateInfo?.type === NftTypeEnum.SemiFungibleESDT) { + await this.triggerCacheInvalidation( + `${updateTopics.collection}-${updateTopics.nonce}`, + CacheEventTypeEnum.AssetRefresh, + ); + } break; + } } } diff --git a/src/modules/rabbitmq/elastic-updates/elastic-updates-events.consumer.ts b/src/modules/rabbitmq/elastic-updates/elastic-updates-events.consumer.ts index 849b11f26..d1e0a3270 100644 --- a/src/modules/rabbitmq/elastic-updates/elastic-updates-events.consumer.ts +++ b/src/modules/rabbitmq/elastic-updates/elastic-updates-events.consumer.ts @@ -5,7 +5,7 @@ import { ElasticUpdatesEventsService } from './elastic-updates-events.service'; @Injectable() export class ElasiticUpdatesConsumer { - constructor(private readonly elasticUpdateService: ElasticUpdatesEventsService) {} + constructor(private readonly elasticUpdateService: ElasticUpdatesEventsService) { } @CompetingRabbitConsumer({ connection: 'default', @@ -14,12 +14,11 @@ export class ElasiticUpdatesConsumer { dlqExchange: process.env.RABBITMQ_DLQ_EXCHANGE, }) async consumeMintBurnAndUpdateEvents(events: any) { + const updateEvents = [NftEventEnum.ESDTNFTBurn, NftEventEnum.ESDTNFTUpdateAttributes, NftEventEnum.ESDTMetaDataUpdate, NftEventEnum.ESDTMetaDataRecreate,] if (events.events && process.env.ENABLE_ELASTIC_UPDATES === 'true') { const mintNftEvents = events?.events?.filter((e: { identifier: NftEventEnum }) => e.identifier === NftEventEnum.ESDTNFTCreate); const burnAndUpdateNftAttributesEvents = events?.events?.filter( - (e: { identifier: NftEventEnum }) => - e.identifier === NftEventEnum.ESDTNFTBurn || e.identifier === NftEventEnum.ESDTNFTUpdateAttributes, - ); + (e: { identifier: NftEventEnum }) => updateEvents.includes(e.identifier)); const mintBurnAndUpdateNftAttributesEvents = [...mintNftEvents, ...burnAndUpdateNftAttributesEvents]; await Promise.all([