Skip to content

Commit

Permalink
feat: Handle Campaign Created Event
Browse files Browse the repository at this point in the history
  • Loading branch information
manoahLinks committed Dec 3, 2024
1 parent 55976ec commit ca6b9a1
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion src/token-giver-indexer/token-giver-indexer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,40 @@ export class TokenGiverIndexerService {
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
private async handleCampaignCreatedEvent(event: starknet.IEvent) {}
private async handleCampaignCreatedEvent(event: starknet.IEvent) {
const [ownerFelt, campaignAddressFelt] = event.keys;
const [tokenIdLow, tokenIdHigh, tokenGiverNftContractAddressFelt] =
event.data;

const owner = validateAndParseAddress(
`0x${FieldElement.toBigInt(ownerFelt).toString(16)}`

Check failure on line 81 in src/token-giver-indexer/token-giver-indexer.service.ts

View workflow job for this annotation

GitHub Actions / lint-and-build-backend

Insert `,`
);

const campaignAddress = validateAndParseAddress(
`0x${FieldElement.toBigInt(campaignAddressFelt).toString(16)}`

Check failure on line 85 in src/token-giver-indexer/token-giver-indexer.service.ts

View workflow job for this annotation

GitHub Actions / lint-and-build-backend

Insert `,`
);

const tokenId = Number(
uint256.uint256ToBN({
low: FieldElement.toBigInt(tokenIdLow),
high: FieldElement.toBigInt(tokenIdHigh),
})

Check failure on line 92 in src/token-giver-indexer/token-giver-indexer.service.ts

View workflow job for this annotation

GitHub Actions / lint-and-build-backend

Insert `,`
);

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

Check failure on line 96 in src/token-giver-indexer/token-giver-indexer.service.ts

View workflow job for this annotation

GitHub Actions / lint-and-build-backend

Insert `,`
);

await this.prismaService.campaign.create({
data: {
token_id: tokenId,
campaign_address: campaignAddress,
campaign_owner: owner,
token_giver_nft_contract_address: tokenGiverNftContractAddress,
createdAt: new Date(), // Ensure you track creation time
},
});
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
private async handleCampaignUpdatedEvent(event: starknet.IEvent) {
Expand Down

0 comments on commit ca6b9a1

Please sign in to comment.