Skip to content

Commit

Permalink
⬆️ Upgrade ponder to v0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
KONFeature committed Dec 13, 2024
1 parent 68d97c6 commit df6813e
Show file tree
Hide file tree
Showing 29 changed files with 92 additions and 104 deletions.
Binary file modified bun.lockb
Binary file not shown.
2 changes: 2 additions & 0 deletions infra/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export function getPonderEntrypoint(type: "indexer" | "reader") {
"--config",
configPath,
command,
"--schema",
"public",
];
}

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

/* -------------------------------------------------------------------------- */
/* 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 "@/generated";
import { countDistinct, eq, inArray } from "@ponder/core";
import { type Address, isAddress } from "viem";
import { ponder } from "ponder:registry";
import {
campaignTable,
interactionEventTable,
productAdministratorTable,
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
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 "@/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
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 "@/generated";
import { ponder } from "ponder:registry";

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 "@/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
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,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,
Expand All @@ -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
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,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,
Expand All @@ -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
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 "@/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
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 "@/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
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 "@/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
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 "@/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(
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 "@/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";

Expand Down
7 changes: 2 additions & 5 deletions packages/ponder/src/campaign/campaignInteractionLink.ts
Original file line number Diff line number Diff line change
@@ -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 }) => {
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 "@/generated";
import { campaignCapResetTable } from "../../ponder.schema";
import { ponder } from "ponder:registry";
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 "@/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 }) => {
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.log.transactionHash,
txHash: event.transaction.hash,
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.log.transactionHash,
txHash: event.transaction.hash,
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 "@/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",
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 "@/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 }) => {
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 "@/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 }) => {
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 "@/generated";
import { interactionEventTable } from "../../ponder.schema";
import { ponder } from "ponder:registry";
import { interactionEventTable } from "ponder:schema";
import { safeIncreaseCampaignsStats } from "./stats";

ponder.on(
Expand Down
10 changes: 5 additions & 5 deletions packages/ponder/src/interactions/stats.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/ponder/src/interactions/webshopInteractions.ts
Original file line number Diff line number Diff line change
@@ -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 }) => {
Expand Down
Loading

0 comments on commit df6813e

Please sign in to comment.