diff --git a/bun.lockb b/bun.lockb index 17e3894..8430dfa 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/infra/utils.ts b/infra/utils.ts index 3585840..db6ed05 100644 --- a/infra/utils.ts +++ b/infra/utils.ts @@ -36,8 +36,6 @@ export function getPonderEntrypoint(type: "indexer" | "reader") { "--config", configPath, command, - "--schema", - $app.stage, ]; } diff --git a/packages/ponder/config/configBuilder.ts b/packages/ponder/config/configBuilder.ts index 7b2126c..02d7644 100644 --- a/packages/ponder/config/configBuilder.ts +++ b/packages/ponder/config/configBuilder.ts @@ -1,5 +1,4 @@ -import { createConfig, mergeAbis } from "ponder"; -import { factory } from "ponder"; +import { createConfig, mergeAbis } from "@ponder/core"; import { http, type Address, @@ -218,14 +217,14 @@ export function createEnvConfig({ referralFeatureFacetAbi, purchaseFeatureFacetAbi, ]), - address: factory({ + factory: { address: deployedAddresses.productInteractionManager as Address, event: parseAbiItem( "event InteractionContractDeployed(uint256 indexed productId, address interactionContract)" ), parameter: "interactionContract", - }), + }, network: contractNetworkConfig, }, // The campaign factory @@ -237,13 +236,13 @@ export function createEnvConfig({ // Every campaigns Campaigns: { abi: mergeAbis([interactionCampaignAbi, referralCampaignAbi]), - address: factory({ + factory: { address: deployedAddresses.campaignFactory as Address, event: parseAbiItem( "event CampaignCreated(address campaign)" ), parameter: "campaign", - }), + }, network: contractNetworkConfig, }, // The campaign banks factory @@ -255,13 +254,13 @@ export function createEnvConfig({ // Every campaign banks CampaignBanks: { abi: campaignBankAbi, - address: factory({ + factory: { address: deployedAddresses.campaignBankFactory as Address, event: parseAbiItem( "event CampaignBankCreated(address campaignBank)" ), parameter: "campaignBank", - }), + }, network: contractNetworkConfig, }, }, diff --git a/packages/ponder/package.json b/packages/ponder/package.json index f97de61..4af5b27 100644 --- a/packages/ponder/package.json +++ b/packages/ponder/package.json @@ -13,22 +13,22 @@ "serve:prod": "ponder --config config/config-prod.ts serve", "serve:dev": "ponder --config config/config-dev.ts serve", "start": "ponder --config config/config-local.ts start", - "start:dev": "ponder --config config/config-dev.ts start --schema dev", - "start:prod": "ponder --config config/config-prod.ts start --schema prod", + "start:dev": "ponder --config config/config-dev.ts start", + "start:prod": "ponder --config config/config-prod.ts start", "typecheck": "tsc", "docker": "bun docker:build && bun docker:run", "docker:build": "docker build --tag ponder-dev .", "docker:run": "docker run -P ponder-dev" }, "dependencies": { + "@ponder/core": "0.7.17", "drizzle-orm": "0.36.4", - "hono": "4.6.14", - "ponder": "^0.8.6", + "hono": "4.6.13", "viem": "^2.21.54" }, "devDependencies": { "@biomejs/biome": "1.9.4", - "@types/node": "^22.10.2", + "@types/node": "^22.10.1", "typescript": "^5.7.2" }, "engines": { diff --git a/packages/ponder/ponder-env.d.ts b/packages/ponder/ponder-env.d.ts index b8c6a63..e7f3009 100644 --- a/packages/ponder/ponder-env.d.ts +++ b/packages/ponder/ponder-env.d.ts @@ -1,15 +1,27 @@ -/// - -declare module "ponder:internal" { - const config: typeof import("./ponder.config.ts"); - const schema: typeof import("./ponder.schema.ts"); -} - -declare module "ponder:schema" { - export * from "./ponder.schema.ts"; -} - // This file enables type checking and editor autocomplete for this Ponder project. // After upgrading, you may find that changes have been made to this file. // If this happens, please commit the changes. Do not manually edit this file. // See https://ponder.sh/docs/getting-started/installation#typescript for more information. + +declare module "@/generated" { + import type { Virtual } from "@ponder/core"; + + type config = typeof import("./ponder.config.ts").default; + type schema = typeof import("./ponder.schema.ts"); + + export const ponder: Virtual.Registry; + + export type EventNames = Virtual.EventNames; + export type Event = Virtual.Event< + config, + name + >; + export type Context = Virtual.Context< + config, + schema, + name + >; + export type ApiContext = Virtual.ApiContext; + export type IndexingFunctionArgs = + Virtual.IndexingFunctionArgs; +} diff --git a/packages/ponder/ponder.schema.ts b/packages/ponder/ponder.schema.ts index 8102538..945e692 100644 --- a/packages/ponder/ponder.schema.ts +++ b/packages/ponder/ponder.schema.ts @@ -1,4 +1,4 @@ -import { index, onchainEnum, onchainTable, primaryKey } from "ponder"; +import { index, onchainEnum, onchainTable, primaryKey } from "@ponder/core"; /* -------------------------------------------------------------------------- */ /* Product related stuff */ diff --git a/packages/ponder/src/api/admin.ts b/packages/ponder/src/api/admin.ts index 38d89ac..1b8e3aa 100644 --- a/packages/ponder/src/api/admin.ts +++ b/packages/ponder/src/api/admin.ts @@ -1,4 +1,6 @@ -import { ponder } from "ponder:registry"; +import { ponder } from "@/generated"; +import { countDistinct, eq, inArray } from "@ponder/core"; +import { type Address, isAddress } from "viem"; import { campaignTable, interactionEventTable, @@ -6,9 +8,7 @@ import { productInteractionContractTable, productTable, referralCampaignStatsTable, -} from "ponder:schema"; -import { countDistinct, eq, inArray } from "ponder"; -import { type Address, isAddress } from "viem"; +} from "../../ponder.schema"; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore: Unreachable code error diff --git a/packages/ponder/src/api/campaign.ts b/packages/ponder/src/api/campaign.ts index 1c3797e..d7e9da3 100644 --- a/packages/ponder/src/api/campaign.ts +++ b/packages/ponder/src/api/campaign.ts @@ -1,7 +1,7 @@ -import { ponder } from "ponder:registry"; -import { bankingContractTable, campaignTable } from "ponder:schema"; -import { eq } from "ponder"; +import { ponder } from "@/generated"; +import { eq } from "@ponder/core"; import { type Address, type Hex, isAddress, isHex } from "viem"; +import { bankingContractTable, campaignTable } from "../../ponder.schema"; import { getTokens } from "./tokens"; // eslint-disable-next-line @typescript-eslint/ban-ts-comment diff --git a/packages/ponder/src/api/index.ts b/packages/ponder/src/api/index.ts index 9fa0fa9..c402444 100644 --- a/packages/ponder/src/api/index.ts +++ b/packages/ponder/src/api/index.ts @@ -1,4 +1,4 @@ -import { ponder } from "ponder:registry"; +import { ponder } from "@/generated"; ponder.get("/hello", async ({ text }) => { return text("Hello!"); diff --git a/packages/ponder/src/api/interactions.ts b/packages/ponder/src/api/interactions.ts index fc81031..a31b58f 100644 --- a/packages/ponder/src/api/interactions.ts +++ b/packages/ponder/src/api/interactions.ts @@ -1,11 +1,11 @@ -import { ponder } from "ponder:registry"; +import { ponder } from "@/generated"; +import { desc, eq } from "@ponder/core"; +import { type Address, isAddress } from "viem"; import { interactionEventTable, productInteractionContractTable, productTable, -} from "ponder:schema"; -import { desc, eq } from "ponder"; -import { type Address, isAddress } from "viem"; +} from "../../ponder.schema"; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore: Unreachable code error diff --git a/packages/ponder/src/api/members.ts b/packages/ponder/src/api/members.ts index 6bf2310..c3332c3 100644 --- a/packages/ponder/src/api/members.ts +++ b/packages/ponder/src/api/members.ts @@ -1,12 +1,4 @@ -import { ponder } from "ponder:registry"; -import { - interactionEventTable, - productAdministratorTable, - productInteractionContractTable, - productTable, - rewardTable, -} from "ponder:schema"; -import type { SQL } from "drizzle-orm"; +import { ponder } from "@/generated"; import { and, asc, @@ -20,8 +12,16 @@ import { min, sql, sum, -} from "ponder"; +} from "@ponder/core"; +import type { SQL } from "drizzle-orm"; import { type Address, type Hex, isAddress } from "viem"; +import { + interactionEventTable, + productAdministratorTable, + productInteractionContractTable, + productTable, + rewardTable, +} from "../../ponder.schema"; /** * Params for the members fetching diff --git a/packages/ponder/src/api/products.ts b/packages/ponder/src/api/products.ts index 9da7ab7..5ae470a 100644 --- a/packages/ponder/src/api/products.ts +++ b/packages/ponder/src/api/products.ts @@ -1,4 +1,6 @@ -import { ponder } from "ponder:registry"; +import { ponder } from "@/generated"; +import { eq, inArray } from "@ponder/core"; +import { type Hex, isHex, keccak256, toHex } from "viem"; import { bankingContractTable, campaignTable, @@ -7,9 +9,7 @@ import { productTable, referralCampaignStatsTable, tokenTable, -} from "ponder:schema"; -import { eq, inArray } from "ponder"; -import { type Hex, isHex, keccak256, toHex } from "viem"; +} from "../../ponder.schema"; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore: Unreachable code error diff --git a/packages/ponder/src/api/rewards.ts b/packages/ponder/src/api/rewards.ts index c316619..393f3f0 100644 --- a/packages/ponder/src/api/rewards.ts +++ b/packages/ponder/src/api/rewards.ts @@ -1,13 +1,13 @@ -import { ponder } from "ponder:registry"; +import { ponder } from "@/generated"; +import { and, desc, eq, not } from "@ponder/core"; +import { type Address, isAddress } from "viem"; import { bankingContractTable, productTable, rewardAddedEventTable, rewardClaimedEventTable, rewardTable, -} from "ponder:schema"; -import { and, desc, eq, not } from "ponder"; -import { type Address, isAddress } from "viem"; +} from "../../ponder.schema"; import { getTokens } from "./tokens"; // eslint-disable-next-line @typescript-eslint/ban-ts-comment diff --git a/packages/ponder/src/api/stats.ts b/packages/ponder/src/api/stats.ts index 97c0695..909bed2 100644 --- a/packages/ponder/src/api/stats.ts +++ b/packages/ponder/src/api/stats.ts @@ -1,10 +1,10 @@ -import { ponder } from "ponder:registry"; +import { ponder } from "@/generated"; +import { count, countDistinct, eq, gte } from "@ponder/core"; import { interactionEventTable, productInteractionContractTable, productTable, -} from "ponder:schema"; -import { count, countDistinct, eq, gte } from "ponder"; +} from "../../ponder.schema"; /** * Get the overall system stats diff --git a/packages/ponder/src/api/tokens.ts b/packages/ponder/src/api/tokens.ts index 2f3b699..8a399ec 100644 --- a/packages/ponder/src/api/tokens.ts +++ b/packages/ponder/src/api/tokens.ts @@ -1,7 +1,7 @@ -import { type ApiContext, ponder } from "ponder:registry"; -import { tokenTable } from "ponder:schema"; -import { eq, inArray } from "ponder"; +import { type ApiContext, ponder } from "@/generated"; +import { eq, inArray } from "@ponder/core"; import { type Address, isAddress } from "viem"; +import { tokenTable } from "../../ponder.schema"; // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore: Unreachable code error diff --git a/packages/ponder/src/campaign/campaignBank.ts b/packages/ponder/src/campaign/campaignBank.ts index 67c590b..f23406b 100644 --- a/packages/ponder/src/campaign/campaignBank.ts +++ b/packages/ponder/src/campaign/campaignBank.ts @@ -1,8 +1,8 @@ import * as console from "node:console"; -import { type Context, ponder } from "ponder:registry"; -import { bankingContractTable, campaignTable } from "ponder:schema"; +import { type Context, ponder } from "@/generated"; import { type Address, isAddressEqual } from "viem"; import { campaignBankAbi } from "../../abis/campaignAbis"; +import { bankingContractTable, campaignTable } from "../../ponder.schema"; import { upsertTokenIfNeeded } from "../token"; ponder.on( diff --git a/packages/ponder/src/campaign/campaignCreation.ts b/packages/ponder/src/campaign/campaignCreation.ts index 2c655cf..35577c6 100644 --- a/packages/ponder/src/campaign/campaignCreation.ts +++ b/packages/ponder/src/campaign/campaignCreation.ts @@ -1,10 +1,10 @@ -import { type Context, ponder } from "ponder:registry"; -import { campaignTable, referralCampaignStatsTable } from "ponder:schema"; +import { type Context, ponder } from "@/generated"; import type { Address } from "viem"; import { interactionCampaignAbi, referralCampaignAbi, } from "../../abis/campaignAbis"; +import { campaignTable, referralCampaignStatsTable } from "../../ponder.schema"; import { emptyCampaignStats } from "../interactions/stats"; import { bytesToString } from "../utils/format"; diff --git a/packages/ponder/src/campaign/campaignInteractionLink.ts b/packages/ponder/src/campaign/campaignInteractionLink.ts index 3b28d9b..1af7bbb 100644 --- a/packages/ponder/src/campaign/campaignInteractionLink.ts +++ b/packages/ponder/src/campaign/campaignInteractionLink.ts @@ -1,5 +1,8 @@ -import { ponder } from "ponder:registry"; -import { campaignTable, productInteractionContractTable } from "ponder:schema"; +import { ponder } from "@/generated"; +import { + campaignTable, + productInteractionContractTable, +} from "../../ponder.schema"; import { upsertNewCampaign } from "./campaignCreation"; ponder.on("ProductInteraction:CampaignAttached", async ({ event, context }) => { diff --git a/packages/ponder/src/campaign/campaignReset.ts b/packages/ponder/src/campaign/campaignReset.ts index 9ab33e2..eb997a9 100644 --- a/packages/ponder/src/campaign/campaignReset.ts +++ b/packages/ponder/src/campaign/campaignReset.ts @@ -1,5 +1,5 @@ -import { ponder } from "ponder:registry"; -import { campaignCapResetTable } from "ponder:schema"; +import { ponder } from "@/generated"; +import { campaignCapResetTable } from "../../ponder.schema"; ponder.on( "Campaigns:DistributionCapReset", diff --git a/packages/ponder/src/campaign/campaignReward.ts b/packages/ponder/src/campaign/campaignReward.ts index f697b22..4825719 100644 --- a/packages/ponder/src/campaign/campaignReward.ts +++ b/packages/ponder/src/campaign/campaignReward.ts @@ -1,10 +1,10 @@ -import { ponder } from "ponder:registry"; +import { ponder } from "@/generated"; import { bankingContractTable, rewardAddedEventTable, rewardClaimedEventTable, rewardTable, -} from "ponder:schema"; +} from "../../ponder.schema"; import { safeIncreaseCampaignsStats } from "../interactions/stats"; ponder.on("CampaignBanks:RewardAdded", async ({ event, context }) => { @@ -49,7 +49,7 @@ ponder.on("CampaignBanks:RewardAdded", async ({ event, context }) => { user: event.args.user, emitter: event.args.emitter, amount: event.args.amount, - txHash: event.transaction.hash, + txHash: event.log.transactionHash, timestamp: event.block.timestamp, }); @@ -104,7 +104,7 @@ ponder.on("CampaignBanks:RewardClaimed", async ({ event, context: { db } }) => { contractId: bankingContract.id, user: event.args.user, amount: event.args.amount, - txHash: event.transaction.hash, + txHash: event.log.transactionHash, timestamp: event.block.timestamp, }); }); diff --git a/packages/ponder/src/interactionDeployments.ts b/packages/ponder/src/interactionDeployments.ts index 1821543..4c24e46 100644 --- a/packages/ponder/src/interactionDeployments.ts +++ b/packages/ponder/src/interactionDeployments.ts @@ -1,6 +1,6 @@ -import { ponder } from "ponder:registry"; -import { productInteractionContractTable } from "ponder:schema"; +import { ponder } from "@/generated"; import { productInteractionDiamondAbi } from "../abis/interactionAbis"; +import { productInteractionContractTable } from "../ponder.schema"; ponder.on( "ProductInteractionManager:InteractionContractDeployed", diff --git a/packages/ponder/src/interactions/pressInteractions.ts b/packages/ponder/src/interactions/pressInteractions.ts index fc716e8..01940d0 100644 --- a/packages/ponder/src/interactions/pressInteractions.ts +++ b/packages/ponder/src/interactions/pressInteractions.ts @@ -1,5 +1,5 @@ -import { ponder } from "ponder:registry"; -import { interactionEventTable } from "ponder:schema"; +import { ponder } from "@/generated"; +import { interactionEventTable } from "../../ponder.schema"; import { safeIncreaseCampaignsStats } from "./stats"; ponder.on("ProductInteraction:ArticleRead", async ({ event, context }) => { diff --git a/packages/ponder/src/interactions/purchaseInteractions.ts b/packages/ponder/src/interactions/purchaseInteractions.ts index c2dbb6a..1ecc377 100644 --- a/packages/ponder/src/interactions/purchaseInteractions.ts +++ b/packages/ponder/src/interactions/purchaseInteractions.ts @@ -1,5 +1,5 @@ -import { ponder } from "ponder:registry"; -import { interactionEventTable } from "ponder:schema"; +import { ponder } from "@/generated"; +import { interactionEventTable } from "../../ponder.schema"; import { safeIncreaseCampaignsStats } from "./stats"; ponder.on("ProductInteraction:PurchaseStarted", async ({ event, context }) => { diff --git a/packages/ponder/src/interactions/referralInteractions.ts b/packages/ponder/src/interactions/referralInteractions.ts index 5a560ae..e8a4478 100644 --- a/packages/ponder/src/interactions/referralInteractions.ts +++ b/packages/ponder/src/interactions/referralInteractions.ts @@ -1,5 +1,5 @@ -import { ponder } from "ponder:registry"; -import { interactionEventTable } from "ponder:schema"; +import { ponder } from "@/generated"; +import { interactionEventTable } from "../../ponder.schema"; import { safeIncreaseCampaignsStats } from "./stats"; ponder.on( diff --git a/packages/ponder/src/interactions/stats.ts b/packages/ponder/src/interactions/stats.ts index b7544b6..5015a71 100644 --- a/packages/ponder/src/interactions/stats.ts +++ b/packages/ponder/src/interactions/stats.ts @@ -1,12 +1,12 @@ -import type { Context } from "ponder:registry"; +import type { Context } from "@/generated"; +import { and, desc, eq } from "@ponder/core"; +import type { Address } from "viem"; +import { interactionCampaignAbi } from "../../abis/campaignAbis"; import { campaignTable, productInteractionContractTable, referralCampaignStatsTable, -} from "ponder:schema"; -import { and, desc, eq } from "ponder"; -import type { Address } from "viem"; -import { interactionCampaignAbi } from "../../abis/campaignAbis"; +} from "../../ponder.schema"; /** * Default campaign stats diff --git a/packages/ponder/src/interactions/webshopInteractions.ts b/packages/ponder/src/interactions/webshopInteractions.ts index 880ebf7..4720fa8 100644 --- a/packages/ponder/src/interactions/webshopInteractions.ts +++ b/packages/ponder/src/interactions/webshopInteractions.ts @@ -1,5 +1,5 @@ -import { ponder } from "ponder:registry"; -import { interactionEventTable } from "ponder:schema"; +import { ponder } from "@/generated"; +import { interactionEventTable } from "../../ponder.schema"; import { safeIncreaseCampaignsStats } from "./stats"; ponder.on("ProductInteraction:WebShopOpenned", async ({ event, context }) => { diff --git a/packages/ponder/src/product.ts b/packages/ponder/src/product.ts index d21e95c..4e30820 100644 --- a/packages/ponder/src/product.ts +++ b/packages/ponder/src/product.ts @@ -1,6 +1,6 @@ -import { ponder } from "ponder:registry"; -import { productTable } from "ponder:schema"; +import { ponder } from "@/generated"; import { productRegistryAbi } from "../abis/registryAbis"; +import { productTable } from "../ponder.schema"; import { bytesToString } from "./utils/format"; ponder.on("ProductRegistry:ProductMinted", async ({ event, context }) => { diff --git a/packages/ponder/src/productAdministrator.ts b/packages/ponder/src/productAdministrator.ts index 8bcb663..1d293ab 100644 --- a/packages/ponder/src/productAdministrator.ts +++ b/packages/ponder/src/productAdministrator.ts @@ -1,6 +1,6 @@ -import { type Context, ponder } from "ponder:registry"; -import { productAdministratorTable } from "ponder:schema"; +import { type Context, ponder } from "@/generated"; import { isAddressEqual, zeroAddress } from "viem"; +import { productAdministratorTable } from "../ponder.schema"; /* * Handle transfer stuff diff --git a/packages/ponder/src/token.ts b/packages/ponder/src/token.ts index f049b72..e1180f9 100644 --- a/packages/ponder/src/token.ts +++ b/packages/ponder/src/token.ts @@ -1,7 +1,7 @@ import console from "node:console"; -import type { Context } from "ponder:registry"; -import { tokenTable } from "ponder:schema"; +import type { Context } from "@/generated"; import { type Address, erc20Abi } from "viem"; +import { tokenTable } from "../ponder.schema"; export async function upsertTokenIfNeeded({ address,