diff --git a/abis/frak-campaign-abis.ts b/abis/frak-campaign-abis.ts index 1ba72d7..198f1e1 100644 --- a/abis/frak-campaign-abis.ts +++ b/abis/frak-campaign-abis.ts @@ -22,13 +22,13 @@ export const campaignFactoryAbi = [ { type: "function", inputs: [ - { name: "_identifier", internalType: "bytes4", type: "bytes4" }, - { name: "_owner", internalType: "address", type: "address" }, { - name: "_contentInteractionManager", - internalType: "address", + name: "_interaction", + internalType: "contract ContentInteractionDiamond", type: "address", }, + { name: "_owner", internalType: "address", type: "address" }, + { name: "_identifier", internalType: "bytes4", type: "bytes4" }, { name: "_initData", internalType: "bytes", type: "bytes" }, ], name: "createCampaign", @@ -62,19 +62,6 @@ export const campaignFactoryAbi = [ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// export const interactionCampaignAbi = [ - { - type: "function", - inputs: [ - { - name: "_interactionContract", - internalType: "address", - type: "address", - }, - ], - name: "allowInteractionContract", - outputs: [], - stateMutability: "nonpayable", - }, { type: "function", inputs: [], @@ -312,11 +299,6 @@ export const referralCampaignAbi = [ type: "tuple", components: [ { name: "token", internalType: "address", type: "address" }, - { - name: "referralTree", - internalType: "bytes32", - type: "bytes32", - }, { name: "initialReward", internalType: "uint256", @@ -357,26 +339,13 @@ export const referralCampaignAbi = [ type: "address", }, { - name: "_contentInterationManager", - internalType: "address", + name: "_interaction", + internalType: "contract ContentInteractionDiamond", type: "address", }, ], stateMutability: "nonpayable", }, - { - type: "function", - inputs: [ - { - name: "_interactionContract", - internalType: "address", - type: "address", - }, - ], - name: "allowInteractionContract", - outputs: [], - stateMutability: "nonpayable", - }, { type: "function", inputs: [], diff --git a/abis/frak-interaction-abis.ts b/abis/frak-interaction-abis.ts index ac4f80d..16deda1 100644 --- a/abis/frak-interaction-abis.ts +++ b/abis/frak-interaction-abis.ts @@ -443,20 +443,6 @@ export const contentInteractionManagerAbi = [ outputs: [], stateMutability: "nonpayable", }, - { - type: "function", - inputs: [ - { name: "_contentId", internalType: "uint256", type: "uint256" }, - { - name: "_campaign", - internalType: "contract InteractionCampaign", - type: "address", - }, - ], - name: "attachCampaign", - outputs: [], - stateMutability: "nonpayable", - }, { type: "function", inputs: [], diff --git a/ponder.config.ts b/ponder.config.ts index 3d91609..ff1946d 100644 --- a/ponder.config.ts +++ b/ponder.config.ts @@ -89,10 +89,10 @@ export default createConfig({ // The interaction manager ContentInteractionManager: { abi: contentInteractionManagerAbi, - address: "0x76091A17B9f0C53Ea826E04bD5E586C143AFC30e", + address: "0xC97D72A8a9d1D2Ed326EB04f2d706A21cEe2B94E", network: { arbitrumSepolia: { - startBlock: 59205615, + startBlock: 60118981, }, }, }, @@ -104,7 +104,7 @@ export default createConfig({ dappInteractionFacetAbi, ]), factory: { - address: "0x76091A17B9f0C53Ea826E04bD5E586C143AFC30e", + address: "0xC97D72A8a9d1D2Ed326EB04f2d706A21cEe2B94E", event: parseAbiItem( "event InteractionContractDeployed(uint256 indexed contentId, address interactionContract)" ), @@ -112,7 +112,7 @@ export default createConfig({ }, network: { arbitrumSepolia: { - startBlock: 59205615, + startBlock: 60118981, }, }, }, @@ -120,13 +120,13 @@ export default createConfig({ Campaigns: { abi: mergeAbis([interactionCampaignAbi, referralCampaignAbi]), factory: { - address: "0x719C9C48dB1622CF7F196012a269cDB96cBC044f", + address: "0x1f65A60340E4D017DdfeE45aA2905b6D79a55672", event: parseAbiItem("event CampaignCreated(address campaign)"), parameter: "campaign", }, network: { arbitrumSepolia: { - startBlock: 59205615, + startBlock: 60118981, }, }, }, diff --git a/ponder.schema.ts b/ponder.schema.ts index f3c4baf..a44d331 100644 --- a/ponder.schema.ts +++ b/ponder.schema.ts @@ -70,7 +70,7 @@ export default createSchema((p) => ({ interactionContracts: p.many("ContentInteractionContract.contentId"), - campaignsLink: p.many("CampaignToContent.contentId"), + campaigns: p.many("Campaign.contentId"), administrators: p.many("ContentAdministrator.contentId"), }), @@ -106,15 +106,6 @@ export default createSchema((p) => ({ name: p.string(), version: p.string(), - attachments: p.many("CampaignToContent.campaignId"), - capResets: p.many("CampaignCapReset.campaignId"), - }), - CampaignToContent: p.createTable({ - id: p.string(), // address - - campaignId: p.hex().references("Campaign.id"), - campaign: p.one("campaignId"), - contentId: p.bigint().references("Content.id"), content: p.one("contentId"), @@ -122,6 +113,8 @@ export default createSchema((p) => ({ attachTimestamp: p.bigint(), detachTimestamp: p.bigint().optional(), + + capResets: p.many("CampaignCapReset.campaignId"), }), CampaignCapReset: p.createTable({ id: p.string(), // campaign address + timestamp diff --git a/src/interactionCampaign.ts b/src/interactionCampaign.ts index d8c62c1..4f26e9e 100644 --- a/src/interactionCampaign.ts +++ b/src/interactionCampaign.ts @@ -3,8 +3,7 @@ import { ponder } from "@/generated"; import { interactionCampaignAbi } from "../abis/frak-campaign-abis"; ponder.on("ContentInteraction:CampaignAttached", async ({ event, context }) => { - const { Campaign, CampaignToContent, ContentInteractionContract } = - context.db; + const { Campaign, ContentInteractionContract } = context.db; // Find the interaction contract const interactionContract = await ContentInteractionContract.findUnique({ @@ -15,42 +14,31 @@ ponder.on("ContentInteraction:CampaignAttached", async ({ event, context }) => { return; } - // Try to find the campaign - const campaign = await Campaign.findUnique({ id: event.args.campaign }); - if (!campaign) { - // If not found, get the metadata and create it - const [name, version] = await context.client.readContract({ - abi: interactionCampaignAbi, - address: event.args.campaign, - functionName: "getMetadata", - }); - await Campaign.create({ - id: event.args.campaign, - data: { - name, - version, - }, - }); - } - - // Insert the content to campaign link - await CampaignToContent.create({ - id: `${event.args.campaign}-${event.log.address}`, - data: { - campaignId: event.args.campaign, + // Get the metadata and create it + const [name, version] = await context.client.readContract({ + abi: interactionCampaignAbi, + address: event.args.campaign, + functionName: "getMetadata", + }); + await Campaign.upsert({ + id: event.args.campaign, + create: { + name, + version, contentId: interactionContract.contentId, attached: true, attachTimestamp: event.block.timestamp, }, + update: {}, }); }); ponder.on("ContentInteraction:CampaignDetached", async ({ event, context }) => { - const { CampaignToContent } = context.db; + const { Campaign } = context.db; // Find the campaign to content and mark it as detached - await CampaignToContent.update({ - id: `${event.args.campaign}-${event.log.address}`, + await Campaign.update({ + id: event.args.campaign, data: { attached: false, detachTimestamp: event.block.timestamp,