diff --git a/bun.lockb b/bun.lockb index 8430dfa..830c6d6 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/infra/utils.ts b/infra/utils.ts index db6ed05..8bd3790 100644 --- a/infra/utils.ts +++ b/infra/utils.ts @@ -36,6 +36,8 @@ export function getPonderEntrypoint(type: "indexer" | "reader") { "--config", configPath, command, + "--schema", + "public", ]; } diff --git a/packages/ponder/config/configBuilder.ts b/packages/ponder/config/configBuilder.ts index 02d7644..7b2126c 100644 --- a/packages/ponder/config/configBuilder.ts +++ b/packages/ponder/config/configBuilder.ts @@ -1,4 +1,5 @@ -import { createConfig, mergeAbis } from "@ponder/core"; +import { createConfig, mergeAbis } from "ponder"; +import { factory } from "ponder"; import { http, type Address, @@ -217,14 +218,14 @@ export function createEnvConfig({ referralFeatureFacetAbi, purchaseFeatureFacetAbi, ]), - factory: { + address: factory({ address: deployedAddresses.productInteractionManager as Address, event: parseAbiItem( "event InteractionContractDeployed(uint256 indexed productId, address interactionContract)" ), parameter: "interactionContract", - }, + }), network: contractNetworkConfig, }, // The campaign factory @@ -236,13 +237,13 @@ export function createEnvConfig({ // Every campaigns Campaigns: { abi: mergeAbis([interactionCampaignAbi, referralCampaignAbi]), - factory: { + address: factory({ address: deployedAddresses.campaignFactory as Address, event: parseAbiItem( "event CampaignCreated(address campaign)" ), parameter: "campaign", - }, + }), network: contractNetworkConfig, }, // The campaign banks factory @@ -254,13 +255,13 @@ export function createEnvConfig({ // Every campaign banks CampaignBanks: { abi: campaignBankAbi, - factory: { + address: 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 4af5b27..f538ee1 100644 --- a/packages/ponder/package.json +++ b/packages/ponder/package.json @@ -21,9 +21,9 @@ "docker:run": "docker run -P ponder-dev" }, "dependencies": { - "@ponder/core": "0.7.17", "drizzle-orm": "0.36.4", "hono": "4.6.13", + "ponder": "^0.8.2", "viem": "^2.21.54" }, "devDependencies": { diff --git a/packages/ponder/ponder-env.d.ts b/packages/ponder/ponder-env.d.ts index e7f3009..b8c6a63 100644 --- a/packages/ponder/ponder-env.d.ts +++ b/packages/ponder/ponder-env.d.ts @@ -1,27 +1,15 @@ +/// + +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 945e692..8102538 100644 --- a/packages/ponder/ponder.schema.ts +++ b/packages/ponder/ponder.schema.ts @@ -1,4 +1,4 @@ -import { index, onchainEnum, onchainTable, primaryKey } from "@ponder/core"; +import { index, onchainEnum, onchainTable, primaryKey } from "ponder"; /* -------------------------------------------------------------------------- */ /* Product related stuff */ diff --git a/packages/ponder/src/api/admin.ts b/packages/ponder/src/api/admin.ts index 1b8e3aa..38d89ac 100644 --- a/packages/ponder/src/api/admin.ts +++ b/packages/ponder/src/api/admin.ts @@ -1,6 +1,4 @@ -import { ponder } from "@/generated"; -import { countDistinct, eq, inArray } from "@ponder/core"; -import { type Address, isAddress } from "viem"; +import { ponder } from "ponder:registry"; import { campaignTable, interactionEventTable, @@ -8,7 +6,9 @@ import { productInteractionContractTable, productTable, referralCampaignStatsTable, -} from "../../ponder.schema"; +} from "ponder:schema"; +import { countDistinct, eq, inArray } from "ponder"; +import { type Address, isAddress } from "viem"; // 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 d7e9da3..1c3797e 100644 --- a/packages/ponder/src/api/campaign.ts +++ b/packages/ponder/src/api/campaign.ts @@ -1,7 +1,7 @@ -import { ponder } from "@/generated"; -import { eq } from "@ponder/core"; +import { ponder } from "ponder:registry"; +import { bankingContractTable, campaignTable } from "ponder:schema"; +import { eq } from "ponder"; 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 c402444..9fa0fa9 100644 --- a/packages/ponder/src/api/index.ts +++ b/packages/ponder/src/api/index.ts @@ -1,4 +1,4 @@ -import { ponder } from "@/generated"; +import { ponder } from "ponder:registry"; 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 a31b58f..fc81031 100644 --- a/packages/ponder/src/api/interactions.ts +++ b/packages/ponder/src/api/interactions.ts @@ -1,11 +1,11 @@ -import { ponder } from "@/generated"; -import { desc, eq } from "@ponder/core"; -import { type Address, isAddress } from "viem"; +import { ponder } from "ponder:registry"; import { interactionEventTable, productInteractionContractTable, productTable, -} from "../../ponder.schema"; +} from "ponder:schema"; +import { desc, eq } from "ponder"; +import { type Address, isAddress } from "viem"; // 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 c3332c3..6bf2310 100644 --- a/packages/ponder/src/api/members.ts +++ b/packages/ponder/src/api/members.ts @@ -1,4 +1,12 @@ -import { ponder } from "@/generated"; +import { ponder } from "ponder:registry"; +import { + interactionEventTable, + productAdministratorTable, + productInteractionContractTable, + productTable, + rewardTable, +} from "ponder:schema"; +import type { SQL } from "drizzle-orm"; import { and, asc, @@ -12,16 +20,8 @@ import { min, sql, sum, -} from "@ponder/core"; -import type { SQL } from "drizzle-orm"; +} from "ponder"; 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 5ae470a..9da7ab7 100644 --- a/packages/ponder/src/api/products.ts +++ b/packages/ponder/src/api/products.ts @@ -1,6 +1,4 @@ -import { ponder } from "@/generated"; -import { eq, inArray } from "@ponder/core"; -import { type Hex, isHex, keccak256, toHex } from "viem"; +import { ponder } from "ponder:registry"; import { bankingContractTable, campaignTable, @@ -9,7 +7,9 @@ import { productTable, referralCampaignStatsTable, tokenTable, -} from "../../ponder.schema"; +} from "ponder:schema"; +import { eq, inArray } from "ponder"; +import { type Hex, isHex, keccak256, toHex } from "viem"; // 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 393f3f0..c316619 100644 --- a/packages/ponder/src/api/rewards.ts +++ b/packages/ponder/src/api/rewards.ts @@ -1,13 +1,13 @@ -import { ponder } from "@/generated"; -import { and, desc, eq, not } from "@ponder/core"; -import { type Address, isAddress } from "viem"; +import { ponder } from "ponder:registry"; import { bankingContractTable, productTable, rewardAddedEventTable, rewardClaimedEventTable, rewardTable, -} from "../../ponder.schema"; +} from "ponder:schema"; +import { and, desc, eq, not } from "ponder"; +import { type Address, isAddress } from "viem"; 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 909bed2..97c0695 100644 --- a/packages/ponder/src/api/stats.ts +++ b/packages/ponder/src/api/stats.ts @@ -1,10 +1,10 @@ -import { ponder } from "@/generated"; -import { count, countDistinct, eq, gte } from "@ponder/core"; +import { ponder } from "ponder:registry"; import { interactionEventTable, productInteractionContractTable, productTable, -} from "../../ponder.schema"; +} from "ponder:schema"; +import { count, countDistinct, eq, gte } from "ponder"; /** * Get the overall system stats diff --git a/packages/ponder/src/api/tokens.ts b/packages/ponder/src/api/tokens.ts index 8a399ec..2f3b699 100644 --- a/packages/ponder/src/api/tokens.ts +++ b/packages/ponder/src/api/tokens.ts @@ -1,7 +1,7 @@ -import { type ApiContext, ponder } from "@/generated"; -import { eq, inArray } from "@ponder/core"; +import { type ApiContext, ponder } from "ponder:registry"; +import { tokenTable } from "ponder:schema"; +import { eq, inArray } from "ponder"; 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 f23406b..67c590b 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 "@/generated"; +import { type Context, ponder } from "ponder:registry"; +import { bankingContractTable, campaignTable } from "ponder:schema"; 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 35577c6..2c655cf 100644 --- a/packages/ponder/src/campaign/campaignCreation.ts +++ b/packages/ponder/src/campaign/campaignCreation.ts @@ -1,10 +1,10 @@ -import { type Context, ponder } from "@/generated"; +import { type Context, ponder } from "ponder:registry"; +import { campaignTable, referralCampaignStatsTable } from "ponder:schema"; 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 1af7bbb..3b28d9b 100644 --- a/packages/ponder/src/campaign/campaignInteractionLink.ts +++ b/packages/ponder/src/campaign/campaignInteractionLink.ts @@ -1,8 +1,5 @@ -import { ponder } from "@/generated"; -import { - campaignTable, - productInteractionContractTable, -} from "../../ponder.schema"; +import { ponder } from "ponder:registry"; +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 eb997a9..9ab33e2 100644 --- a/packages/ponder/src/campaign/campaignReset.ts +++ b/packages/ponder/src/campaign/campaignReset.ts @@ -1,5 +1,5 @@ -import { ponder } from "@/generated"; -import { campaignCapResetTable } from "../../ponder.schema"; +import { ponder } from "ponder:registry"; +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 4825719..f697b22 100644 --- a/packages/ponder/src/campaign/campaignReward.ts +++ b/packages/ponder/src/campaign/campaignReward.ts @@ -1,10 +1,10 @@ -import { ponder } from "@/generated"; +import { ponder } from "ponder:registry"; 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.log.transactionHash, + txHash: event.transaction.hash, 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.log.transactionHash, + txHash: event.transaction.hash, timestamp: event.block.timestamp, }); }); diff --git a/packages/ponder/src/interactionDeployments.ts b/packages/ponder/src/interactionDeployments.ts index 4c24e46..1821543 100644 --- a/packages/ponder/src/interactionDeployments.ts +++ b/packages/ponder/src/interactionDeployments.ts @@ -1,6 +1,6 @@ -import { ponder } from "@/generated"; +import { ponder } from "ponder:registry"; +import { productInteractionContractTable } from "ponder:schema"; 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 01940d0..fc716e8 100644 --- a/packages/ponder/src/interactions/pressInteractions.ts +++ b/packages/ponder/src/interactions/pressInteractions.ts @@ -1,5 +1,5 @@ -import { ponder } from "@/generated"; -import { interactionEventTable } from "../../ponder.schema"; +import { ponder } from "ponder:registry"; +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 1ecc377..c2dbb6a 100644 --- a/packages/ponder/src/interactions/purchaseInteractions.ts +++ b/packages/ponder/src/interactions/purchaseInteractions.ts @@ -1,5 +1,5 @@ -import { ponder } from "@/generated"; -import { interactionEventTable } from "../../ponder.schema"; +import { ponder } from "ponder:registry"; +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 e8a4478..5a560ae 100644 --- a/packages/ponder/src/interactions/referralInteractions.ts +++ b/packages/ponder/src/interactions/referralInteractions.ts @@ -1,5 +1,5 @@ -import { ponder } from "@/generated"; -import { interactionEventTable } from "../../ponder.schema"; +import { ponder } from "ponder:registry"; +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 5015a71..b7544b6 100644 --- a/packages/ponder/src/interactions/stats.ts +++ b/packages/ponder/src/interactions/stats.ts @@ -1,12 +1,12 @@ -import type { Context } from "@/generated"; -import { and, desc, eq } from "@ponder/core"; -import type { Address } from "viem"; -import { interactionCampaignAbi } from "../../abis/campaignAbis"; +import type { Context } from "ponder:registry"; import { campaignTable, productInteractionContractTable, referralCampaignStatsTable, -} from "../../ponder.schema"; +} from "ponder:schema"; +import { and, desc, eq } from "ponder"; +import type { Address } from "viem"; +import { interactionCampaignAbi } from "../../abis/campaignAbis"; /** * Default campaign stats diff --git a/packages/ponder/src/interactions/webshopInteractions.ts b/packages/ponder/src/interactions/webshopInteractions.ts index 4720fa8..880ebf7 100644 --- a/packages/ponder/src/interactions/webshopInteractions.ts +++ b/packages/ponder/src/interactions/webshopInteractions.ts @@ -1,5 +1,5 @@ -import { ponder } from "@/generated"; -import { interactionEventTable } from "../../ponder.schema"; +import { ponder } from "ponder:registry"; +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 4e30820..d21e95c 100644 --- a/packages/ponder/src/product.ts +++ b/packages/ponder/src/product.ts @@ -1,6 +1,6 @@ -import { ponder } from "@/generated"; +import { ponder } from "ponder:registry"; +import { productTable } from "ponder:schema"; 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 1d293ab..8bcb663 100644 --- a/packages/ponder/src/productAdministrator.ts +++ b/packages/ponder/src/productAdministrator.ts @@ -1,6 +1,6 @@ -import { type Context, ponder } from "@/generated"; +import { type Context, ponder } from "ponder:registry"; +import { productAdministratorTable } from "ponder:schema"; 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 e1180f9..f049b72 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 "@/generated"; +import type { Context } from "ponder:registry"; +import { tokenTable } from "ponder:schema"; import { type Address, erc20Abi } from "viem"; -import { tokenTable } from "../ponder.schema"; export async function upsertTokenIfNeeded({ address,