Skip to content

Commit

Permalink
Merge pull request #21 from Joewizy/main
Browse files Browse the repository at this point in the history
tokenGiverNftEvents
  • Loading branch information
EjembiEmmanuel authored Dec 17, 2024
2 parents af702f4 + 42ebfa4 commit 8228040
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion src/token-giver-indexer/token-giver-indexer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ export class TokenGiverIndexerService {
):
this.handleDonationReceivedEvent(event);
break;
case validateAndParseAddress(
hash.getSelectorFromName(
constants.event_names.DEPLOYED_TOKEN_GIVER_NFT,
),
):
this.handleDeployedTokenGiverNftEvent(event);
break;
default:
this.logger.warn(`Unknown event type: ${eventKey}`);
}
Expand Down Expand Up @@ -95,5 +102,33 @@ export class TokenGiverIndexerService {
private async handleDonationReceivedEvent(event: starknet.IEvent) {}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
private async handleDeployedTokenGiverNftEvent(event: starknet.IEvent) {}
private async handleDeployedTokenGiverNftEvent(event: starknet.IEvent) {
const [
campaignIdLow,
campaignIdHigh,
tokenGiverNftContractAddressFelt,
blockTimestampFelt,
] = event.data;

const campaignId = Number(
uint256.uint256ToBN({
low: FieldElement.toBigInt(campaignIdLow),
high: FieldElement.toBigInt(campaignIdHigh),
}),
);

const tokenGiverNftContractAddress = validateAndParseAddress(
`0x${FieldElement.toBigInt(tokenGiverNftContractAddressFelt).toString(16)}`,
);

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const blockTimestamp = FieldElement.toBigInt(blockTimestampFelt);

await this.prismaService.campaign.update({
where: { id: campaignId },
data: {
token_giver_nft_contract_address: tokenGiverNftContractAddress,
},
});
}
}

0 comments on commit 8228040

Please sign in to comment.