Skip to content

Commit

Permalink
Revert "⬆️ Upgrade to ponder 0.8.6"
Browse files Browse the repository at this point in the history
This reverts commit 4866132.
Because of the error `no schema has been selected to create in` from `Object.createTriggers`
  • Loading branch information
KONFeature committed Dec 17, 2024
1 parent 4866132 commit 162d15e
Show file tree
Hide file tree
Showing 29 changed files with 108 additions and 96 deletions.
Binary file modified bun.lockb
Binary file not shown.
2 changes: 0 additions & 2 deletions infra/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ export function getPonderEntrypoint(type: "indexer" | "reader") {
"--config",
configPath,
command,
"--schema",
$app.stage,
];
}

Expand Down
15 changes: 7 additions & 8 deletions packages/ponder/config/configBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createConfig, mergeAbis } from "ponder";
import { factory } from "ponder";
import { createConfig, mergeAbis } from "@ponder/core";
import {
http,
type Address,
Expand Down Expand Up @@ -218,14 +217,14 @@ export function createEnvConfig<NetworkKey extends string>({
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
Expand All @@ -237,13 +236,13 @@ export function createEnvConfig<NetworkKey extends string>({
// 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
Expand All @@ -255,13 +254,13 @@ export function createEnvConfig<NetworkKey extends string>({
// Every campaign banks
CampaignBanks: {
abi: campaignBankAbi,
address: factory({
factory: {
address: deployedAddresses.campaignBankFactory as Address,
event: parseAbiItem(
"event CampaignBankCreated(address campaignBank)"
),
parameter: "campaignBank",
}),
},
network: contractNetworkConfig,
},
},
Expand Down
10 changes: 5 additions & 5 deletions packages/ponder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
34 changes: 23 additions & 11 deletions packages/ponder/ponder-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
/// <reference types="ponder/virtual" />

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<config, schema>;

export type EventNames = Virtual.EventNames<config>;
export type Event<name extends EventNames = EventNames> = Virtual.Event<
config,
name
>;
export type Context<name extends EventNames = EventNames> = Virtual.Context<
config,
schema,
name
>;
export type ApiContext = Virtual.ApiContext<schema>;
export type IndexingFunctionArgs<name extends EventNames = EventNames> =
Virtual.IndexingFunctionArgs<config, schema, name>;
}
2 changes: 1 addition & 1 deletion packages/ponder/ponder.schema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { index, onchainEnum, onchainTable, primaryKey } from "ponder";
import { index, onchainEnum, onchainTable, primaryKey } from "@ponder/core";

/* -------------------------------------------------------------------------- */
/* Product related stuff */
Expand Down
8 changes: 4 additions & 4 deletions packages/ponder/src/api/admin.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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,
productAdministratorTable,
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
Expand Down
6 changes: 3 additions & 3 deletions packages/ponder/src/api/campaign.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/ponder/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ponder } from "ponder:registry";
import { ponder } from "@/generated";

ponder.get("/hello", async ({ text }) => {
return text("Hello!");
Expand Down
8 changes: 4 additions & 4 deletions packages/ponder/src/api/interactions.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 10 additions & 10 deletions packages/ponder/src/api/members.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions packages/ponder/src/api/products.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions packages/ponder/src/api/rewards.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions packages/ponder/src/api/stats.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions packages/ponder/src/api/tokens.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/ponder/src/campaign/campaignBank.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
4 changes: 2 additions & 2 deletions packages/ponder/src/campaign/campaignCreation.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
7 changes: 5 additions & 2 deletions packages/ponder/src/campaign/campaignInteractionLink.ts
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/ponder/src/campaign/campaignReset.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
8 changes: 4 additions & 4 deletions packages/ponder/src/campaign/campaignReward.ts
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand Down Expand Up @@ -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,
});

Expand Down Expand Up @@ -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,
});
});
4 changes: 2 additions & 2 deletions packages/ponder/src/interactionDeployments.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions packages/ponder/src/interactions/pressInteractions.ts
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/ponder/src/interactions/purchaseInteractions.ts
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/ponder/src/interactions/referralInteractions.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
Loading

0 comments on commit 162d15e

Please sign in to comment.