Skip to content

Commit

Permalink
✨ Add the webshop opened interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
KONFeature committed Oct 14, 2024
1 parent a9735b6 commit 13500a0
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 86 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@types/node": "^22.5.4",
"aws-cdk-lib": "2.142.1",
"sst": "2.43.6",
"typescript": "^5.6.2"
"typescript": "^5.6.3"
},
"engines": {
"node": ">=18.14"
Expand Down
4 changes: 2 additions & 2 deletions packages/erpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"@types/node": "^22.4.0",
"aws-cdk-lib": "2.142.1",
"sst": "2.43.6",
"typescript": "^5.3.2",
"viem": "^2.21.19"
"typescript": "^5.6.3",
"viem": "^2.21.25"
},
"engines": {
"node": ">=18.14"
Expand Down
2 changes: 1 addition & 1 deletion packages/ponder/abis/addresses.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"campaignBankFactory": "0x00000000003604CF2d09f4Aa3B878843A765015d",
"campaignFactory": "0x0000000000278e0EFbC5968020A798AaB1571E5c",
"facetFactory": "0x000000000068C43436b8970Ee8791718f50b9643",
"facetFactory": "0x00000000990d7c3D3AeCfa0caA17750d9dA97C7e",
"mUSDToken": "0x43838DCb58a61325eC5F31FD70aB8cd3540733d1",
"productAdministratorRegistry": "0x0000000000000823EaD12075a50A2a6520966e5c",
"productInteractionManager": "0x0000000000009720dc2B0D893f7Ec2a878d21AeC",
Expand Down
13 changes: 13 additions & 0 deletions packages/ponder/abis/interactionAbis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1356,5 +1356,18 @@ export const webShopInteractionFacetAbi = [
outputs: [{ name: "", internalType: "uint8", type: "uint8" }],
stateMutability: "pure",
},
{
type: "event",
anonymous: false,
inputs: [
{
name: "user",
internalType: "address",
type: "address",
indexed: false,
},
],
name: "WebShopOpenned",
},
{ type: "error", inputs: [], name: "UnknownInteraction" },
] as const;
2 changes: 2 additions & 0 deletions packages/ponder/config/configBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
productInteractionManagerAbi,
purchaseFeatureFacetAbi,
referralFeatureFacetAbi,
webShopInteractionFacetAbi,
} from "../abis/interactionAbis";
import {
productAdministratorRegistryAbi,
Expand Down Expand Up @@ -101,6 +102,7 @@ export function createEnvConfig<NetworkKey extends string>({
// Each facets
pressInteractionFacetAbi,
dappInteractionFacetAbi,
webShopInteractionFacetAbi,
referralFeatureFacetAbi,
purchaseFeatureFacetAbi,
]),
Expand Down
8 changes: 4 additions & 4 deletions packages/ponder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
"typecheck": "tsc"
},
"dependencies": {
"@ponder/core": "^0.6.7",
"@ponder/core": "^0.6.15",
"drizzle-orm": "^0.31.4",
"hono": "^4.6.3",
"viem": "^2.21.19"
"hono": "^4.6.4",
"viem": "^2.21.25"
},
"devDependencies": {
"@biomejs/biome": "1.9.3",
"@types/aws-lambda": "8.10.138",
"@types/node": "^22.4.0",
"aws-cdk-lib": "2.142.1",
"sst": "2.43.6",
"typescript": "^5.3.2"
"typescript": "^5.6.3"
},
"trustedDependencies": [
"better_sqlite3"
Expand Down
5 changes: 5 additions & 0 deletions packages/ponder/ponder.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ export default createSchema((p) => ({
// Purchase type
"PURCHASE_STARTED",
"PURCHASE_COMPLETED",
// Webshop type
"WEBSHOP_OPENNED",
]),

/* -------------------------------------------------------------------------- */
Expand Down Expand Up @@ -160,6 +162,9 @@ export default createSchema((p) => ({
purchaseStartedInteractions: p.bigint(),
purchaseCompletedInteractions: p.bigint(),

// webshop related interactions
webshopOpenned: p.bigint(),

totalRewards: p.bigint(),
},
{
Expand Down
1 change: 1 addition & 0 deletions packages/ponder/src/interactions/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const emptyCampaignStats = {
createReferredLinkInteractions: 0n,
purchaseStartedInteractions: 0n,
purchaseCompletedInteractions: 0n,
webshopOpenned: 0n,
totalRewards: 0n,
};

Expand Down
27 changes: 27 additions & 0 deletions packages/ponder/src/interactions/webshopInteractions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { ponder } from "@/generated";
import { increaseCampaignsStats } from "./stats";

ponder.on("ProductInteraction:WebShopOpenned", async ({ event, context }) => {
const { InteractionEvent } = context.db;

// Insert the press event
await InteractionEvent.create({
id: event.log.id,
data: {
interactionId: event.log.address,
user: event.args.user,
type: "WEBSHOP_OPENNED",
timestamp: event.block.timestamp,
},
});

// Update the current campaigns stats
await increaseCampaignsStats({
interactionEmitter: event.log.address,
blockNumber: event.block.number,
context,
increments: {
webshopOpenned: 1n,
},
});
});
Loading

0 comments on commit 13500a0

Please sign in to comment.