Fix #22: Remove 'any' usage and replace shims with proper typed handlers

- Updated all ponder event handlers to use proper TypeScript types
- Removed all 'any' type annotations from event handlers
- Handlers now properly leverage TypeScript's type inference
- Improved type safety across the ponder indexer

Fixes #22
This commit is contained in:
openhands 2025-09-25 18:28:20 +02:00
parent 7da7b12b6b
commit 316ea0380f
5 changed files with 2555 additions and 10 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2545
services/ponder/pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -10,7 +10,7 @@ import {
const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000" as const;
ponder.on("Kraiken:Transfer", async ({ event, context }: any) => {
ponder.on("Kraiken:Transfer", async ({ event, context }) => {
const { from, to, value } = event.args;
await ensureStatsExists(context, event.block.timestamp);
@ -44,7 +44,7 @@ ponder.on("Kraiken:Transfer", async ({ event, context }: any) => {
await updateHourlyData(context, event.block.timestamp);
});
ponder.on("StatsBlock:block", async ({ event, context }: any) => {
ponder.on("StatsBlock:block", async ({ event, context }) => {
await ensureStatsExists(context, event.block.timestamp);
await updateHourlyData(context, event.block.timestamp);
});

View file

@ -12,7 +12,7 @@ import {
const ZERO = 0n;
async function getKraikenTotalSupply(context: any) {
async function getKraikenTotalSupply(context: Context) {
return context.client.readContract({
abi: context.contracts.Kraiken.abi,
address: context.contracts.Kraiken.address,
@ -25,7 +25,7 @@ function toShareRatio(share: bigint, stakeTotalSupply: bigint): number {
return Number(share) / Number(stakeTotalSupply);
}
ponder.on("Stake:PositionCreated", async ({ event, context }: any) => {
ponder.on("Stake:PositionCreated", async ({ event, context }) => {
await ensureStatsExists(context, event.block.timestamp);
const stakeTotalSupply = await getStakeTotalSupply(context);
@ -53,7 +53,7 @@ ponder.on("Stake:PositionCreated", async ({ event, context }: any) => {
await refreshOutstandingStake(context);
});
ponder.on("Stake:PositionRemoved", async ({ event, context }: any) => {
ponder.on("Stake:PositionRemoved", async ({ event, context }) => {
await ensureStatsExists(context, event.block.timestamp);
const positionId = event.args.positionId.toString();
@ -75,7 +75,7 @@ ponder.on("Stake:PositionRemoved", async ({ event, context }: any) => {
await updateHourlyData(context, event.block.timestamp);
});
ponder.on("Stake:PositionShrunk", async ({ event, context }: any) => {
ponder.on("Stake:PositionShrunk", async ({ event, context }) => {
await ensureStatsExists(context, event.block.timestamp);
const positionId = event.args.positionId.toString();
@ -97,7 +97,7 @@ ponder.on("Stake:PositionShrunk", async ({ event, context }: any) => {
await updateHourlyData(context, event.block.timestamp);
});
ponder.on("Stake:PositionTaxPaid", async ({ event, context }: any) => {
ponder.on("Stake:PositionTaxPaid", async ({ event, context }) => {
await ensureStatsExists(context, event.block.timestamp);
await updateHourlyData(context, event.block.timestamp);
@ -133,7 +133,7 @@ ponder.on("Stake:PositionTaxPaid", async ({ event, context }: any) => {
await updateHourlyData(context, event.block.timestamp);
});
ponder.on("Stake:PositionRateHiked", async ({ event, context }: any) => {
ponder.on("Stake:PositionRateHiked", async ({ event, context }) => {
const positionId = event.args.positionId.toString();
await context.db.update(positions, { id: positionId }).set({
taxRate: TAX_RATES[Number(event.args.newTaxRate)] || 0,