diff --git a/src/common/constants.ts b/src/common/constants.ts index 5719ac6..8d8ca1e 100644 --- a/src/common/constants.ts +++ b/src/common/constants.ts @@ -12,9 +12,8 @@ export default { }, event_names: { CAMPAIGN_CREATED: 'CreateCampaign', - CAMPAIGN_UPDATED: 'CampaignUpdated', DONATION_RECEIVED: 'DonationCreated', - CAMPAIGN_DELETED: 'CampaignDeleted', + DEPLOYED_TOKEN_GIVER_NFT: 'DeployedTokenGiverNFT', }, apibara: { maxReceiveMessageLength: 128 * 1_048_576, diff --git a/src/token-giver-indexer/token-giver-indexer.service.ts b/src/token-giver-indexer/token-giver-indexer.service.ts index f644ef7..77aba6f 100644 --- a/src/token-giver-indexer/token-giver-indexer.service.ts +++ b/src/token-giver-indexer/token-giver-indexer.service.ts @@ -21,15 +21,9 @@ export class TokenGiverIndexerService { validateAndParseAddress( hash.getSelectorFromName(constants.event_names.CAMPAIGN_CREATED), ), - validateAndParseAddress( - hash.getSelectorFromName(constants.event_names.CAMPAIGN_UPDATED), - ), validateAndParseAddress( hash.getSelectorFromName(constants.event_names.DONATION_RECEIVED), ), - validateAndParseAddress( - hash.getSelectorFromName(constants.event_names.CAMPAIGN_DELETED), - ), ]; } @@ -51,21 +45,11 @@ export class TokenGiverIndexerService { ): this.handleCampaignCreatedEvent(event); break; - case validateAndParseAddress( - hash.getSelectorFromName(constants.event_names.CAMPAIGN_UPDATED), - ): - this.handleCampaignUpdatedEvent(event); - break; case validateAndParseAddress( hash.getSelectorFromName(constants.event_names.DONATION_RECEIVED), ): this.handleDonationReceivedEvent(event); break; - case validateAndParseAddress( - hash.getSelectorFromName(constants.event_names.CAMPAIGN_DELETED), - ): - this.handleCampaignDeletedEvent(event); - break; default: this.logger.warn(`Unknown event type: ${eventKey}`); } @@ -107,53 +91,9 @@ export class TokenGiverIndexerService { }); } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - private async handleCampaignUpdatedEvent(event: starknet.IEvent) { - const [ownerFelt, campaignAddressFelt] = event.keys; - - const [tokenIdLow, tokenIdtHigh, tokenGiverNftContractAddressFelt] = - event.data; - - const owner = validateAndParseAddress( - `0x${FieldElement.toBigInt(ownerFelt).toString(16)}`, - ); - - const campaignAddress = validateAndParseAddress( - `0x${FieldElement.toBigInt(campaignAddressFelt).toString(16)}`, - ); - - const tokenId = Number( - uint256.uint256ToBN({ - low: FieldElement.toBigInt(tokenIdLow), - high: FieldElement.toBigInt(tokenIdtHigh), - }), - ); - - const tokenGiverNftContractAddress = validateAndParseAddress( - `0x${FieldElement.toBigInt(tokenGiverNftContractAddressFelt).toString(16)}`, - ); - - const campaign = await this.prismaService.campaign.findFirst({ - where: { token_id: tokenId }, - }); - - if (!campaign) { - this.logger.warn(`Campaign with token Id ${tokenId} doesn't exist`); - } - - await this.prismaService.campaign.update({ - where: { id: campaign.id }, - data: { - campaign_address: campaignAddress, - campaign_owner: owner, - token_giver_nft_contract_address: tokenGiverNftContractAddress, - }, - }); - } - // eslint-disable-next-line @typescript-eslint/no-unused-vars private async handleDonationReceivedEvent(event: starknet.IEvent) {} // eslint-disable-next-line @typescript-eslint/no-unused-vars - private async handleCampaignDeletedEvent(event: starknet.IEvent) {} + private async handleDeployedTokenGiverNftEvent(event: starknet.IEvent) {} }