From 004c0b2ed0ba66f2c6e22870fad066a04d7ac6f9 Mon Sep 17 00:00:00 2001 From: KONFeature Date: Wed, 12 Jun 2024 18:07:39 +0200 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=A8=20Add=20smart=20contracts=20v2=20?= =?UTF-8?q?abis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- abis/frak-campaign-abis.ts | 651 ++++++++++++++++++ abis/frak-interaction-abis.ts | 1172 +++++++++++++++++++++++++++++++++ abis/frak-registry-abis.ts | 850 ++++++++++++++++++++++++ ponder.config.ts | 48 +- ponder.schema.ts | 145 ++-- src/erc20.ts | 70 -- 6 files changed, 2788 insertions(+), 148 deletions(-) create mode 100644 abis/frak-campaign-abis.ts create mode 100644 abis/frak-interaction-abis.ts create mode 100644 abis/frak-registry-abis.ts delete mode 100644 src/erc20.ts diff --git a/abis/frak-campaign-abis.ts b/abis/frak-campaign-abis.ts new file mode 100644 index 0000000..fecf389 --- /dev/null +++ b/abis/frak-campaign-abis.ts @@ -0,0 +1,651 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// InteractionCampaign +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +export const interactionCampaignAbi = [ + { + type: "function", + inputs: [ + { + name: "_interactionContract", + internalType: "address", + type: "address", + }, + ], + name: "allowInteractionContract", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "cancelOwnershipHandover", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "pendingOwner", internalType: "address", type: "address" }, + ], + name: "completeOwnershipHandover", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [], + name: "disallowMe", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "getMetadata", + outputs: [ + { name: "name", internalType: "string", type: "string" }, + { name: "version", internalType: "string", type: "string" }, + ], + stateMutability: "pure", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "grantRoles", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [{ name: "_data", internalType: "bytes", type: "bytes" }], + name: "handleInteraction", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "hasAllRoles", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "hasAnyRole", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "isActive", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "owner", + outputs: [{ name: "result", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "pendingOwner", internalType: "address", type: "address" }, + ], + name: "ownershipHandoverExpiresAt", + outputs: [{ name: "result", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "renounceOwnership", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [{ name: "roles", internalType: "uint256", type: "uint256" }], + name: "renounceRoles", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [], + name: "requestOwnershipHandover", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "revokeRoles", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [{ name: "user", internalType: "address", type: "address" }], + name: "rolesOf", + outputs: [{ name: "roles", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { + name: "_contentType", + internalType: "ContentTypes", + type: "uint256", + }, + ], + name: "supportContentType", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "newOwner", internalType: "address", type: "address" }, + ], + name: "transferOwnership", + outputs: [], + stateMutability: "payable", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "pendingOwner", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "OwnershipHandoverCanceled", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "pendingOwner", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "OwnershipHandoverRequested", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "oldOwner", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "newOwner", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "OwnershipTransferred", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "user", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "roles", + internalType: "uint256", + type: "uint256", + indexed: true, + }, + ], + name: "RolesUpdated", + }, + { type: "error", inputs: [], name: "AlreadyInitialized" }, + { type: "error", inputs: [], name: "NewOwnerIsZeroAddress" }, + { type: "error", inputs: [], name: "NoHandoverRequest" }, + { type: "error", inputs: [], name: "Unauthorized" }, +] as const; + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// ReferralCampaign +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +export const referralCampaignAbi = [ + { + type: "constructor", + inputs: [ + { name: "_token", internalType: "address", type: "address" }, + { + name: "_explorationLevel", + internalType: "uint256", + type: "uint256", + }, + { + name: "_perLevelPercentage", + internalType: "uint256", + type: "uint256", + }, + { + name: "_initialReferrerReward", + internalType: "uint256", + type: "uint256", + }, + { + name: "_dailyDistributionCap", + internalType: "uint256", + type: "uint256", + }, + { name: "_referralTree", internalType: "bytes32", type: "bytes32" }, + { + name: "_referralRegistry", + internalType: "contract ReferralRegistry", + type: "address", + }, + { name: "_owner", internalType: "address", type: "address" }, + { + name: "_contentInterationManager", + internalType: "address", + type: "address", + }, + ], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { + name: "_interactionContract", + internalType: "address", + type: "address", + }, + ], + name: "allowInteractionContract", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "cancelOwnershipHandover", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "pendingOwner", internalType: "address", type: "address" }, + ], + name: "completeOwnershipHandover", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [], + name: "disallowMe", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "_user", internalType: "address", type: "address" }, + { + name: "_initialAmount", + internalType: "uint256", + type: "uint256", + }, + ], + name: "distributeTokenToUserReferrers", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "getMetadata", + outputs: [ + { name: "name", internalType: "string", type: "string" }, + { name: "version", internalType: "string", type: "string" }, + ], + stateMutability: "pure", + }, + { + type: "function", + inputs: [ + { name: "_user", internalType: "address", type: "address" }, + { name: "_token", internalType: "address", type: "address" }, + ], + name: "getPendingAmount", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "_token", internalType: "address", type: "address" }], + name: "getTotalPending", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "grantRoles", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [{ name: "_data", internalType: "bytes", type: "bytes" }], + name: "handleInteraction", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "hasAllRoles", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "hasAnyRole", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "isActive", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "owner", + outputs: [{ name: "result", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "pendingOwner", internalType: "address", type: "address" }, + ], + name: "ownershipHandoverExpiresAt", + outputs: [{ name: "result", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "_user", internalType: "address", type: "address" }, + { name: "_token", internalType: "address", type: "address" }, + ], + name: "pullReward", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "_user", internalType: "address", type: "address" }, + { name: "_tokens", internalType: "address[]", type: "address[]" }, + ], + name: "pullRewards", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "renounceOwnership", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [{ name: "roles", internalType: "uint256", type: "uint256" }], + name: "renounceRoles", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [], + name: "requestOwnershipHandover", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "revokeRoles", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [{ name: "user", internalType: "address", type: "address" }], + name: "rolesOf", + outputs: [{ name: "roles", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { + name: "_contentType", + internalType: "ContentTypes", + type: "uint256", + }, + ], + name: "supportContentType", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "pure", + }, + { + type: "function", + inputs: [ + { name: "newOwner", internalType: "address", type: "address" }, + ], + name: "transferOwnership", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [], + name: "withdraw", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "previousTimestamp", + internalType: "uint48", + type: "uint48", + indexed: false, + }, + { + name: "distributedAmount", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + ], + name: "DailyDistrubutionCapReset", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "pendingOwner", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "OwnershipHandoverCanceled", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "pendingOwner", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "OwnershipHandoverRequested", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "oldOwner", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "newOwner", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "OwnershipTransferred", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "user", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "token", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "amount", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + ], + name: "RewardAdded", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "user", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "token", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "amount", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + ], + name: "RewardClaimed", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "user", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "roles", + internalType: "uint256", + type: "uint256", + indexed: true, + }, + ], + name: "RolesUpdated", + }, + { type: "error", inputs: [], name: "AlreadyInitialized" }, + { type: "error", inputs: [], name: "DailyDistributionCapReached" }, + { type: "error", inputs: [], name: "InvalidConfig" }, + { type: "error", inputs: [], name: "NewOwnerIsZeroAddress" }, + { type: "error", inputs: [], name: "NoHandoverRequest" }, + { type: "error", inputs: [], name: "NotEnoughToken" }, + { type: "error", inputs: [], name: "Reentrancy" }, + { type: "error", inputs: [], name: "Unauthorized" }, +] as const; diff --git a/abis/frak-interaction-abis.ts b/abis/frak-interaction-abis.ts new file mode 100644 index 0000000..38a1686 --- /dev/null +++ b/abis/frak-interaction-abis.ts @@ -0,0 +1,1172 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// ContentInteractionDiamond +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +export const contentInteractionDiamondAbi = [ + { + type: "constructor", + inputs: [ + { name: "_contentId", internalType: "uint256", type: "uint256" }, + { + name: "_referralRegistry", + internalType: "contract ReferralRegistry", + type: "address", + }, + { + name: "_interactionMananger", + internalType: "address", + type: "address", + }, + { + name: "_interactionManangerOwner", + internalType: "address", + type: "address", + }, + { name: "_contentOwner", internalType: "address", type: "address" }, + ], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { + name: "_campaign", + internalType: "contract InteractionCampaign", + type: "address", + }, + ], + name: "attachCampaign", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "cancelOwnershipHandover", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "pendingOwner", internalType: "address", type: "address" }, + ], + name: "completeOwnershipHandover", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { + name: "_contentTypeDenominator", + internalType: "uint8", + type: "uint8", + }, + { name: "_call", internalType: "bytes", type: "bytes" }, + ], + name: "delegateToFacet", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { + name: "_contentTypes", + internalType: "ContentTypes", + type: "uint256", + }, + ], + name: "deleteFacets", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { + name: "_campaigns", + internalType: "contract InteractionCampaign[]", + type: "address[]", + }, + ], + name: "detachCampaigns", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "eip712Domain", + outputs: [ + { name: "fields", internalType: "bytes1", type: "bytes1" }, + { name: "name", internalType: "string", type: "string" }, + { name: "version", internalType: "string", type: "string" }, + { name: "chainId", internalType: "uint256", type: "uint256" }, + { + name: "verifyingContract", + internalType: "address", + type: "address", + }, + { name: "salt", internalType: "bytes32", type: "bytes32" }, + { + name: "extensions", + internalType: "uint256[]", + type: "uint256[]", + }, + ], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "getCampaigns", + outputs: [ + { + name: "", + internalType: "contract InteractionCampaign[]", + type: "address[]", + }, + ], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "getContentId", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "getDomainSeparator", + outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "_denominator", internalType: "uint8", type: "uint8" }, + ], + name: "getFacet", + outputs: [ + { + name: "", + internalType: "contract IInteractionFacet", + type: "address", + }, + ], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { + name: "_interactionData", + internalType: "bytes32", + type: "bytes32", + }, + { name: "_user", internalType: "address", type: "address" }, + ], + name: "getNonceForInteraction", + outputs: [{ name: "", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "getReferralTree", + outputs: [{ name: "tree", internalType: "bytes32", type: "bytes32" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "grantRoles", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "_interaction", internalType: "bytes", type: "bytes" }, + { name: "_signature", internalType: "bytes", type: "bytes" }, + ], + name: "handleInteraction", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "hasAllRoles", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "hasAnyRole", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "owner", + outputs: [{ name: "result", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "pendingOwner", internalType: "address", type: "address" }, + ], + name: "ownershipHandoverExpiresAt", + outputs: [{ name: "result", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "renounceOwnership", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [{ name: "roles", internalType: "uint256", type: "uint256" }], + name: "renounceRoles", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [], + name: "requestOwnershipHandover", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "revokeRoles", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [{ name: "user", internalType: "address", type: "address" }], + name: "rolesOf", + outputs: [{ name: "roles", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { + name: "facets", + internalType: "contract IInteractionFacet[]", + type: "address[]", + }, + ], + name: "setFacets", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "newOwner", internalType: "address", type: "address" }, + ], + name: "transferOwnership", + outputs: [], + stateMutability: "payable", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "version", + internalType: "uint64", + type: "uint64", + indexed: false, + }, + ], + name: "Initialized", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "pendingOwner", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "OwnershipHandoverCanceled", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "pendingOwner", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "OwnershipHandoverRequested", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "oldOwner", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "newOwner", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "OwnershipTransferred", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "user", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "roles", + internalType: "uint256", + type: "uint256", + indexed: true, + }, + ], + name: "RolesUpdated", + }, + { type: "error", inputs: [], name: "AlreadyInitialized" }, + { type: "error", inputs: [], name: "CampaignAlreadyPresent" }, + { type: "error", inputs: [], name: "InteractionHandlingFailed" }, + { type: "error", inputs: [], name: "InvalidInitialization" }, + { type: "error", inputs: [], name: "NewOwnerIsZeroAddress" }, + { type: "error", inputs: [], name: "NoHandoverRequest" }, + { type: "error", inputs: [], name: "NotInitializing" }, + { type: "error", inputs: [], name: "UnandledContentType" }, + { type: "error", inputs: [], name: "Unauthorized" }, + { type: "error", inputs: [], name: "WrongInteractionSigner" }, +] as const; + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// ContentInteractionManager +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +export const contentInteractionManagerAbi = [ + { + type: "constructor", + inputs: [ + { + name: "_contentRegistry", + internalType: "contract ContentRegistry", + type: "address", + }, + { + name: "_referralRegistry", + internalType: "contract ReferralRegistry", + type: "address", + }, + ], + 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: [], + name: "cancelOwnershipHandover", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "pendingOwner", internalType: "address", type: "address" }, + ], + name: "completeOwnershipHandover", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "_contentId", internalType: "uint256", type: "uint256" }, + ], + name: "deleteInteractionContract", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "_contentId", internalType: "uint256", type: "uint256" }, + ], + name: "deployInteractionContract", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "_contentId", internalType: "uint256", type: "uint256" }, + { + name: "_campaigns", + internalType: "contract InteractionCampaign[]", + type: "address[]", + }, + ], + name: "detachCampaigns", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "_contentId", internalType: "uint256", type: "uint256" }, + ], + name: "getInteractionContract", + outputs: [ + { + name: "interactionContract", + internalType: "contract ContentInteractionDiamond", + type: "address", + }, + ], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "grantRoles", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "hasAllRoles", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "hasAnyRole", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "_owner", internalType: "address", type: "address" }, + { + name: "_facetsFactory", + internalType: "contract InteractionFacetsFactory", + type: "address", + }, + ], + name: "init", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "owner", + outputs: [{ name: "result", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "pendingOwner", internalType: "address", type: "address" }, + ], + name: "ownershipHandoverExpiresAt", + outputs: [{ name: "result", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "proxiableUUID", + outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "renounceOwnership", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [{ name: "roles", internalType: "uint256", type: "uint256" }], + name: "renounceRoles", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [], + name: "requestOwnershipHandover", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "revokeRoles", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [{ name: "user", internalType: "address", type: "address" }], + name: "rolesOf", + outputs: [{ name: "roles", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "newOwner", internalType: "address", type: "address" }, + ], + name: "transferOwnership", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { + name: "_facetsFactory", + internalType: "contract InteractionFacetsFactory", + type: "address", + }, + ], + name: "updateFacetsFactory", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "_contentId", internalType: "uint256", type: "uint256" }, + ], + name: "updateInteractionContract", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { + name: "newImplementation", + internalType: "address", + type: "address", + }, + { name: "data", internalType: "bytes", type: "bytes" }, + ], + name: "upgradeToAndCall", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "_newWallet", internalType: "address", type: "address" }, + ], + name: "walletLinked", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "contentId", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + { + name: "campaign", + internalType: "address", + type: "address", + indexed: false, + }, + ], + name: "CampaignAttached", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "contentId", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + { + name: "campaigns", + internalType: "contract InteractionCampaign[]", + type: "address[]", + indexed: false, + }, + ], + name: "CampaignsDetached", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "version", + internalType: "uint64", + type: "uint64", + indexed: false, + }, + ], + name: "Initialized", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "contentId", + internalType: "uint256", + type: "uint256", + indexed: true, + }, + ], + name: "InteractionContractDeleted", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "contentId", + internalType: "uint256", + type: "uint256", + indexed: true, + }, + { + name: "interactionContract", + internalType: "contract ContentInteractionDiamond", + type: "address", + indexed: false, + }, + ], + name: "InteractionContractDeployed", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "contentId", + internalType: "uint256", + type: "uint256", + indexed: true, + }, + ], + name: "InteractionContractUpdated", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "pendingOwner", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "OwnershipHandoverCanceled", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "pendingOwner", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "OwnershipHandoverRequested", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "oldOwner", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "newOwner", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "OwnershipTransferred", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "user", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "roles", + internalType: "uint256", + type: "uint256", + indexed: true, + }, + ], + name: "RolesUpdated", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "implementation", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "Upgraded", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "prevWallet", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "newWallet", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "WalletLinked", + }, + { type: "error", inputs: [], name: "AlreadyInitialized" }, + { type: "error", inputs: [], name: "CantHandleContentTypes" }, + { type: "error", inputs: [], name: "InteractionContractAlreadyDeployed" }, + { type: "error", inputs: [], name: "InvalidInitialization" }, + { type: "error", inputs: [], name: "NewOwnerIsZeroAddress" }, + { type: "error", inputs: [], name: "NoHandoverRequest" }, + { type: "error", inputs: [], name: "NoInteractionContractFound" }, + { type: "error", inputs: [], name: "NotInitializing" }, + { type: "error", inputs: [], name: "Unauthorized" }, + { type: "error", inputs: [], name: "UnauthorizedCallContext" }, + { type: "error", inputs: [], name: "UpgradeFailed" }, +] as const; + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// DappStorageFacet +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +export const dappStorageFacetAbi = [ + { type: "constructor", inputs: [], stateMutability: "nonpayable" }, + { type: "fallback", stateMutability: "nonpayable" }, + { + type: "function", + inputs: [], + name: "cancelOwnershipHandover", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "pendingOwner", internalType: "address", type: "address" }, + ], + name: "completeOwnershipHandover", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [], + name: "contentTypeDenominator", + outputs: [{ name: "", internalType: "uint8", type: "uint8" }], + stateMutability: "pure", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "grantRoles", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "hasAllRoles", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "hasAnyRole", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "owner", + outputs: [{ name: "result", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "pendingOwner", internalType: "address", type: "address" }, + ], + name: "ownershipHandoverExpiresAt", + outputs: [{ name: "result", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "renounceOwnership", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [{ name: "roles", internalType: "uint256", type: "uint256" }], + name: "renounceRoles", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [], + name: "requestOwnershipHandover", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "revokeRoles", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [{ name: "user", internalType: "address", type: "address" }], + name: "rolesOf", + outputs: [{ name: "roles", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "_contractId", internalType: "uint256", type: "uint256" }, + { + name: "_contractAddress", + internalType: "address", + type: "address", + }, + ], + name: "setContentContract", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "newOwner", internalType: "address", type: "address" }, + ], + name: "transferOwnership", + outputs: [], + stateMutability: "payable", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "pendingOwner", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "OwnershipHandoverCanceled", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "pendingOwner", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "OwnershipHandoverRequested", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "oldOwner", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "newOwner", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "OwnershipTransferred", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "user", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "roles", + internalType: "uint256", + type: "uint256", + indexed: true, + }, + ], + name: "RolesUpdated", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "smartContract", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "slot", + internalType: "uint256", + type: "uint256", + indexed: true, + }, + { + name: "value", + internalType: "uint256", + type: "uint256", + indexed: false, + }, + ], + name: "StorageUpdated", + }, + { type: "error", inputs: [], name: "AlreadyInitialized" }, + { + type: "error", + inputs: [{ name: "index", internalType: "uint256", type: "uint256" }], + name: "InvalidProof", + }, + { type: "error", inputs: [], name: "NewOwnerIsZeroAddress" }, + { type: "error", inputs: [], name: "NoHandoverRequest" }, + { type: "error", inputs: [], name: "Unauthorized" }, + { type: "error", inputs: [], name: "UnknownContract" }, + { type: "error", inputs: [], name: "UnknownInteraction" }, +] as const; + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// PressInteractionFacet +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +export const pressInteractionFacetAbi = [ + { + type: "constructor", + inputs: [ + { + name: "_referralRegistry", + internalType: "contract ReferralRegistry", + type: "address", + }, + ], + stateMutability: "nonpayable", + }, + { type: "fallback", stateMutability: "nonpayable" }, + { + type: "function", + inputs: [], + name: "contentTypeDenominator", + outputs: [{ name: "", internalType: "uint8", type: "uint8" }], + stateMutability: "pure", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "articleId", + internalType: "bytes32", + type: "bytes32", + indexed: true, + }, + { + name: "user", + internalType: "address", + type: "address", + indexed: false, + }, + ], + name: "ArticleOpened", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "articleId", + internalType: "bytes32", + type: "bytes32", + indexed: true, + }, + { + name: "user", + internalType: "address", + type: "address", + indexed: false, + }, + ], + name: "ArticleRead", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "user", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "referrer", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "UserReferred", + }, + { type: "error", inputs: [], name: "UnknownInteraction" }, +] as const; diff --git a/abis/frak-registry-abis.ts b/abis/frak-registry-abis.ts new file mode 100644 index 0000000..8f021c5 --- /dev/null +++ b/abis/frak-registry-abis.ts @@ -0,0 +1,850 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// ContentRegistry +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +export const contentRegistryAbi = [ + { + type: "constructor", + inputs: [{ name: "_owner", internalType: "address", type: "address" }], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "account", internalType: "address", type: "address" }, + { name: "id", internalType: "uint256", type: "uint256" }, + ], + name: "approve", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [{ name: "owner", internalType: "address", type: "address" }], + name: "balanceOf", + outputs: [{ name: "result", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "cancelOwnershipHandover", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "pendingOwner", internalType: "address", type: "address" }, + ], + name: "completeOwnershipHandover", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [{ name: "id", internalType: "uint256", type: "uint256" }], + name: "getApproved", + outputs: [{ name: "result", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "_contentId", internalType: "uint256", type: "uint256" }, + ], + name: "getContentTypes", + outputs: [{ name: "", internalType: "ContentTypes", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "_contentId", internalType: "uint256", type: "uint256" }, + ], + name: "getMetadata", + outputs: [ + { + name: "", + internalType: "struct Metadata", + type: "tuple", + components: [ + { + name: "contentTypes", + internalType: "ContentTypes", + type: "uint256", + }, + { name: "name", internalType: "string", type: "string" }, + { name: "domain", internalType: "string", type: "string" }, + ], + }, + ], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "grantRoles", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "hasAllRoles", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "hasAnyRole", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "owner", internalType: "address", type: "address" }, + { name: "operator", internalType: "address", type: "address" }, + ], + name: "isApprovedForAll", + outputs: [{ name: "result", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "_contentId", internalType: "uint256", type: "uint256" }, + { name: "_caller", internalType: "address", type: "address" }, + ], + name: "isAuthorized", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "_contentId", internalType: "uint256", type: "uint256" }, + ], + name: "isExistingContent", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { + name: "_contentTypes", + internalType: "ContentTypes", + type: "uint256", + }, + { name: "_name", internalType: "string", type: "string" }, + { name: "_domain", internalType: "string", type: "string" }, + ], + name: "mint", + outputs: [{ name: "id", internalType: "uint256", type: "uint256" }], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "name", + outputs: [{ name: "", internalType: "string", type: "string" }], + stateMutability: "pure", + }, + { + type: "function", + inputs: [], + name: "owner", + outputs: [{ name: "result", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [{ name: "id", internalType: "uint256", type: "uint256" }], + name: "ownerOf", + outputs: [{ name: "result", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "pendingOwner", internalType: "address", type: "address" }, + ], + name: "ownershipHandoverExpiresAt", + outputs: [{ name: "result", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "renounceOwnership", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [{ name: "roles", internalType: "uint256", type: "uint256" }], + name: "renounceRoles", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [], + name: "requestOwnershipHandover", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "revokeRoles", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [{ name: "user", internalType: "address", type: "address" }], + name: "rolesOf", + outputs: [{ name: "roles", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "from", internalType: "address", type: "address" }, + { name: "to", internalType: "address", type: "address" }, + { name: "id", internalType: "uint256", type: "uint256" }, + ], + name: "safeTransferFrom", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "from", internalType: "address", type: "address" }, + { name: "to", internalType: "address", type: "address" }, + { name: "id", internalType: "uint256", type: "uint256" }, + { name: "data", internalType: "bytes", type: "bytes" }, + ], + name: "safeTransferFrom", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "operator", internalType: "address", type: "address" }, + { name: "isApproved", internalType: "bool", type: "bool" }, + ], + name: "setApprovalForAll", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "interfaceId", internalType: "bytes4", type: "bytes4" }, + ], + name: "supportsInterface", + outputs: [{ name: "result", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "symbol", + outputs: [{ name: "", internalType: "string", type: "string" }], + stateMutability: "pure", + }, + { + type: "function", + inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }], + name: "tokenURI", + outputs: [{ name: "", internalType: "string", type: "string" }], + stateMutability: "pure", + }, + { + type: "function", + inputs: [ + { name: "from", internalType: "address", type: "address" }, + { name: "to", internalType: "address", type: "address" }, + { name: "id", internalType: "uint256", type: "uint256" }, + ], + name: "transferFrom", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "newOwner", internalType: "address", type: "address" }, + ], + name: "transferOwnership", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "_contentId", internalType: "uint256", type: "uint256" }, + { + name: "_contentTypes", + internalType: "ContentTypes", + type: "uint256", + }, + { name: "_name", internalType: "string", type: "string" }, + ], + name: "updateMetadata", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "owner", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "account", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "id", + internalType: "uint256", + type: "uint256", + indexed: true, + }, + ], + name: "Approval", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "owner", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "operator", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "isApproved", + internalType: "bool", + type: "bool", + indexed: false, + }, + ], + name: "ApprovalForAll", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "contentId", + internalType: "uint256", + type: "uint256", + indexed: true, + }, + { + name: "domain", + internalType: "string", + type: "string", + indexed: false, + }, + { + name: "contentTypes", + internalType: "ContentTypes", + type: "uint256", + indexed: false, + }, + { + name: "name", + internalType: "string", + type: "string", + indexed: false, + }, + ], + name: "ContentMinted", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "contentId", + internalType: "uint256", + type: "uint256", + indexed: true, + }, + { + name: "contentTypes", + internalType: "ContentTypes", + type: "uint256", + indexed: false, + }, + { + name: "name", + internalType: "string", + type: "string", + indexed: false, + }, + ], + name: "ContentUpdated", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "pendingOwner", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "OwnershipHandoverCanceled", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "pendingOwner", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "OwnershipHandoverRequested", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "oldOwner", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "newOwner", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "OwnershipTransferred", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "user", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "roles", + internalType: "uint256", + type: "uint256", + indexed: true, + }, + ], + name: "RolesUpdated", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "from", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "to", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "id", + internalType: "uint256", + type: "uint256", + indexed: true, + }, + ], + name: "Transfer", + }, + { type: "error", inputs: [], name: "AccountBalanceOverflow" }, + { type: "error", inputs: [], name: "AlreadyExistingContent" }, + { type: "error", inputs: [], name: "AlreadyInitialized" }, + { type: "error", inputs: [], name: "BalanceQueryForZeroAddress" }, + { type: "error", inputs: [], name: "InvalidNameOrDomain" }, + { type: "error", inputs: [], name: "NewOwnerIsZeroAddress" }, + { type: "error", inputs: [], name: "NoHandoverRequest" }, + { type: "error", inputs: [], name: "NotOwnerNorApproved" }, + { type: "error", inputs: [], name: "TokenAlreadyExists" }, + { type: "error", inputs: [], name: "TokenDoesNotExist" }, + { type: "error", inputs: [], name: "TransferFromIncorrectOwner" }, + { + type: "error", + inputs: [], + name: "TransferToNonERC721ReceiverImplementer", + }, + { type: "error", inputs: [], name: "TransferToZeroAddress" }, + { type: "error", inputs: [], name: "Unauthorized" }, +] as const; + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// ReferralRegistry +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +export const referralRegistryAbi = [ + { + type: "constructor", + inputs: [{ name: "_owner", internalType: "address", type: "address" }], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [], + name: "cancelOwnershipHandover", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "pendingOwner", internalType: "address", type: "address" }, + ], + name: "completeOwnershipHandover", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "_selector", internalType: "bytes32", type: "bytes32" }, + { name: "_referee", internalType: "address", type: "address" }, + ], + name: "getAllReferrers", + outputs: [ + { + name: "referrerChains", + internalType: "address[]", + type: "address[]", + }, + ], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "_selector", internalType: "bytes32", type: "bytes32" }, + { name: "_referee", internalType: "address", type: "address" }, + { name: "_maxLength", internalType: "uint256", type: "uint256" }, + ], + name: "getCappedReferrers", + outputs: [ + { + name: "referrerChains", + internalType: "address[]", + type: "address[]", + }, + ], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "_selector", internalType: "bytes32", type: "bytes32" }, + { name: "_referee", internalType: "address", type: "address" }, + ], + name: "getReferrer", + outputs: [ + { name: "referrer", internalType: "address", type: "address" }, + ], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "_selector", internalType: "bytes32", type: "bytes32" }, + { name: "_owner", internalType: "address", type: "address" }, + ], + name: "grantAccessToTree", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "grantRoles", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "hasAllRoles", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "hasAnyRole", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "_selector", internalType: "bytes32", type: "bytes32" }, + { name: "_owner", internalType: "address", type: "address" }, + ], + name: "isAllowedOnTree", + outputs: [{ name: "", internalType: "bool", type: "bool" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "owner", + outputs: [{ name: "result", internalType: "address", type: "address" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "pendingOwner", internalType: "address", type: "address" }, + ], + name: "ownershipHandoverExpiresAt", + outputs: [{ name: "result", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [], + name: "renounceOwnership", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [{ name: "roles", internalType: "uint256", type: "uint256" }], + name: "renounceRoles", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [], + name: "requestOwnershipHandover", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [ + { name: "user", internalType: "address", type: "address" }, + { name: "roles", internalType: "uint256", type: "uint256" }, + ], + name: "revokeRoles", + outputs: [], + stateMutability: "payable", + }, + { + type: "function", + inputs: [{ name: "user", internalType: "address", type: "address" }], + name: "rolesOf", + outputs: [{ name: "roles", internalType: "uint256", type: "uint256" }], + stateMutability: "view", + }, + { + type: "function", + inputs: [ + { name: "_selector", internalType: "bytes32", type: "bytes32" }, + { name: "_user", internalType: "address", type: "address" }, + { name: "_referrer", internalType: "address", type: "address" }, + ], + name: "saveReferrer", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "_selector", internalType: "bytes32", type: "bytes32" }, + { name: "_newOwner", internalType: "address", type: "address" }, + ], + name: "transferAccessToTree", + outputs: [], + stateMutability: "nonpayable", + }, + { + type: "function", + inputs: [ + { name: "newOwner", internalType: "address", type: "address" }, + ], + name: "transferOwnership", + outputs: [], + stateMutability: "payable", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "pendingOwner", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "OwnershipHandoverCanceled", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "pendingOwner", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "OwnershipHandoverRequested", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "oldOwner", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "newOwner", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "OwnershipTransferred", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "user", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "roles", + internalType: "uint256", + type: "uint256", + indexed: true, + }, + ], + name: "RolesUpdated", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "tree", + internalType: "bytes32", + type: "bytes32", + indexed: true, + }, + { + name: "referer", + internalType: "address", + type: "address", + indexed: true, + }, + { + name: "referee", + internalType: "address", + type: "address", + indexed: true, + }, + ], + name: "UserReferred", + }, + { + type: "error", + inputs: [ + { name: "tree", internalType: "bytes32", type: "bytes32" }, + { + name: "currentReferrer", + internalType: "address", + type: "address", + }, + ], + name: "AlreadyHaveReferer", + }, + { + type: "error", + inputs: [{ name: "tree", internalType: "bytes32", type: "bytes32" }], + name: "AlreadyInRefererChain", + }, + { type: "error", inputs: [], name: "AlreadyInitialized" }, + { type: "error", inputs: [], name: "InvalidReferrer" }, + { type: "error", inputs: [], name: "InvalidTreeOwner" }, + { type: "error", inputs: [], name: "NewOwnerIsZeroAddress" }, + { type: "error", inputs: [], name: "NoHandoverRequest" }, + { type: "error", inputs: [], name: "NotAllowedOnTheGivenTree" }, + { type: "error", inputs: [], name: "Unauthorized" }, +] as const; diff --git a/ponder.config.ts b/ponder.config.ts index 070f90a..8a35a33 100644 --- a/ponder.config.ts +++ b/ponder.config.ts @@ -1,6 +1,7 @@ import { createConfig } from "@ponder/core"; -import { http } from "viem"; -import { erc20ABI } from "./abis/erc20ABI"; +import {http, parseAbiItem} from "viem"; +import {contentInteractionDiamondAbi, contentInteractionManagerAbi} from "./abis/frak-interaction-abis"; +import { contentRegistryAbi } from "./abis/frak-registry-abis"; import { multiWebAuthNValidatorV2Abi } from "./abis/multiWebAuthNValidatorABI"; const pollingConfig = { @@ -43,16 +44,10 @@ export default createConfig({ }, }, contracts: { - // The erc20 tokens to index - ERC20: { - abi: erc20ABI, - network: "arbitrumSepolia", - address: "0x9584A61F70cC4BEF5b8B5f588A1d35740f0C7ae2", - startBlock: 29562417, - }, // The WebAuthN validator to index WebAuthNValidator: { abi: multiWebAuthNValidatorV2Abi, + address: "0xD546c4Ba2e8e5e5c961C36e6Db0460Be03425808", network: { arbitrumSepolia: { startBlock: 35765963, @@ -70,7 +65,40 @@ export default createConfig({ startBlock: 56157675, },*/ }, - address: "0xD546c4Ba2e8e5e5c961C36e6Db0460Be03425808", }, + // The content registry + ContentRegistry: { + abi: contentRegistryAbi, + address: "0xc02209e937dB50C80AA1A280f9172163D8aC6a38", + network: { + arbitrumSepolia: { + startBlock: 52222107, + }, + }, + }, + // The interaction manager + ContentInteractionManager: { + abi: contentInteractionManagerAbi, + address: "0x71a54b7Edb803b0FB6c7A930794BcA13587Af21b", + network: { + arbitrumSepolia: { + startBlock: 52222107, + }, + }, + }, + // Every content interactions + ContentInteraction: { + abi: contentInteractionDiamondAbi, + factory: { + address: "0x71a54b7Edb803b0FB6c7A930794BcA13587Af21b", + event: parseAbiItem("event InteractionContractDeployed(uint256 indexed contentId, address interactionContract)"), + parameter: "interactionContract", + }, + network: { + arbitrumSepolia: { + startBlock: 52222107, + }, + }, + } }, }); diff --git a/ponder.schema.ts b/ponder.schema.ts index b7b6dca..7a392f0 100644 --- a/ponder.schema.ts +++ b/ponder.schema.ts @@ -6,52 +6,9 @@ export default createSchema((p) => ({ // Id the wallet address id: p.hex(), - // The linked token Balance - balances: p.many("TokenBalance.accountId"), - - // The linked transfer events - transferFromEvents: p.many("TransferEvent.fromId"), - transferToEvents: p.many("TransferEvent.toId"), - // The linked webauthn validators validators: p.many("MultiWebAuthNValidator.accountId"), }), - // Token we are tracking - Token: p.createTable( - { - // Id the token address + chain id - id: p.hex(), - address: p.hex(), - chain: p.int(), - }, - { - // Indexes - chainIndex: p.index("chain"), - // Address index - addressIndex: p.index("address"), - } - ), - // Token balance for each users - TokenBalance: p.createTable( - { - // Id the token address + user address + chain id - id: p.hex(), - - balance: p.bigint(), - - // The account this balance is linked to - accountId: p.hex().references("Account.id"), - account: p.one("accountId"), - - // The token this balance is linked to - tokenId: p.hex().references("Token.id"), - token: p.one("tokenId"), - }, - { - accountIndex: p.index("accountId"), - tokenIndex: p.index("tokenId"), - } - ), // Validator we are tracking MultiWebAuthNValidator: p.createTable({ // Id is a concatenation of chain + account address @@ -79,31 +36,6 @@ export default createSchema((p) => ({ changeLogEvents: p.many("PasskeyChangeLogEvent.passkeyId"), }), - // Erc20 Transfer events - TransferEvent: p.createTable( - { - id: p.string(), - amount: p.bigint(), - - tokenId: p.hex().references("Token.id"), - token: p.one("tokenId"), - - timestamp: p.int(), - - fromId: p.hex().references("Account.id"), - toId: p.hex().references("Account.id"), - - from: p.one("fromId"), - to: p.one("toId"), - }, - { - // From and to indexes - fromIndex: p.index("fromId"), - toIndex: p.index("toId"), - // Search indexes - tokenIndex: p.index("tokenId"), - } - ), // WebAuthN Validator related events PrimaryPasskeyChangedEvent: p.createTable({ id: p.string(), @@ -124,4 +56,81 @@ export default createSchema((p) => ({ timestamp: p.int(), chain: p.int(), }), + + // Content related stuff + Content: p.createTable({ + id: p.bigint(), + + domain: p.string(), + contentTypes: p.bigint(), + name: p.string(), + + updatedEvents: p.many("ContentUpdatedEvent.contentId"), + interactionContracts: p.many("ContentInteractionContract.contentId"), + + campaignsLink: p.many("CampaignToContent.contentId"), + }), + ContentUpdatedEvent: p.createTable({ + id: p.string(), + + name: p.string(), + contentTypes: p.bigint(), + + contentId: p.bigint().references("Content.id"), + content: p.one("contentId"), + + timestamp: p.int(), + }), + + // Interaction related + ContentInteractionContract: p.createTable({ + id: p.hex(), // address + + contentId: p.bigint().references("Content.id"), + content: p.one("contentId"), + + created: p.int(), + lastUpdate: p.int().optional(), + removedTimestamp: p.int().optional(), + }), + + // Campaign related + Campaign: p.createTable({ + id: p.hex(), + + name: p.string(), + version: p.string(), + + attachments: p.many("CampaignToContent.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"), + + attached: p.boolean(), + + attachTimestamp: p.int(), + detachTimestamp: p.int().optional(), + }), + + // Press events + PressEvent: p.createTable({ + id: p.string(), + + interactionId: p.hex().references("ContentInteractionContract.id"), + interaction: p.one("interactionId"), + + user: p.hex(), + type: p.enum("PressEventType"), + data: p.json(), + + timestamp: p.int(), + }), + + PressEventType: p.createEnum(["OPEN_ARTICLE", "READ_ARTICLE", "REFERRED"]), })); diff --git a/src/erc20.ts b/src/erc20.ts deleted file mode 100644 index 38e3c7f..0000000 --- a/src/erc20.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { ponder } from "@/generated"; -import { encodePacked, keccak256 } from "viem"; - -ponder.on("ERC20:Transfer", async ({ event, context }) => { - const { Account, Token, TokenBalance, TransferEvent } = context.db; - - // Create an Account for the sender, or update the balance if it already exists. - await Account.upsert({ id: event.args.from }); - - // Create an Account for the recipient, or update the balance if it already exists. - await Account.upsert({ id: event.args.to }); - - // Update or insert the token - const tokenId = keccak256( - encodePacked( - ["address", "uint32"], - [event.log.address, context.network.chainId] - ) - ); - await Token.upsert({ - id: tokenId, - create: { - address: event.log.address, - chain: context.network.chainId, - }, - update: ({ current }) => current, - }); - - // Update or insert the users balance on this token - await TokenBalance.upsert({ - id: keccak256( - encodePacked(["bytes32", "address"], [tokenId, event.args.from]) - ), - create: { - accountId: event.args.from, - tokenId, - balance: 0n, - }, - update: ({ current }) => ({ - balance: current.balance - event.args.amount, - }), - }); - await TokenBalance.upsert({ - id: keccak256( - encodePacked(["bytes32", "address"], [tokenId, event.args.to]) - ), - create: { - accountId: event.args.to, - tokenId, - balance: 0n, - }, - update: ({ current }) => ({ - balance: current.balance + event.args.amount, - }), - }); - - // Create a TransferEvent. - await TransferEvent.create({ - id: event.log.id, - data: { - // Metadata info - tokenId: tokenId, - // Transfer info - fromId: event.args.from, - toId: event.args.to, - amount: event.args.amount, - timestamp: Number(event.block.timestamp), - }, - }); -}); From a68ac289b2cd4c35975b195a06f4b012d8cf9128 Mon Sep 17 00:00:00 2001 From: KONFeature Date: Thu, 13 Jun 2024 18:47:28 +0200 Subject: [PATCH 2/3] =?UTF-8?q?=E2=9C=A8=20Add=20event=20handlers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- abis/frak-interaction-abis.ts | 78 +++++++++++++++++------------------ ponder.config.ts | 35 ++++++++++------ ponder.schema.ts | 29 +++++++------ src/content.ts | 55 ++++++++++++++++++++++++ src/interactionCampaign.ts | 59 ++++++++++++++++++++++++++ src/interactionDeployments.ts | 40 ++++++++++++++++++ src/pressInteractions.ts | 48 +++++++++++++++++++++ 7 files changed, 281 insertions(+), 63 deletions(-) create mode 100644 src/content.ts create mode 100644 src/interactionCampaign.ts create mode 100644 src/interactionDeployments.ts create mode 100644 src/pressInteractions.ts diff --git a/abis/frak-interaction-abis.ts b/abis/frak-interaction-abis.ts index 38a1686..1e92c31 100644 --- a/abis/frak-interaction-abis.ts +++ b/abis/frak-interaction-abis.ts @@ -297,6 +297,32 @@ export const contentInteractionDiamondAbi = [ outputs: [], stateMutability: "payable", }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "campaign", + internalType: "contract InteractionCampaign", + type: "address", + indexed: false, + }, + ], + name: "CampaignAttached", + }, + { + type: "event", + anonymous: false, + inputs: [ + { + name: "campaign", + internalType: "contract InteractionCampaign", + type: "address", + indexed: false, + }, + ], + name: "CampaignDetached", + }, { type: "event", anonymous: false, @@ -643,44 +669,6 @@ export const contentInteractionManagerAbi = [ outputs: [], stateMutability: "nonpayable", }, - { - type: "event", - anonymous: false, - inputs: [ - { - name: "contentId", - internalType: "uint256", - type: "uint256", - indexed: false, - }, - { - name: "campaign", - internalType: "address", - type: "address", - indexed: false, - }, - ], - name: "CampaignAttached", - }, - { - type: "event", - anonymous: false, - inputs: [ - { - name: "contentId", - internalType: "uint256", - type: "uint256", - indexed: false, - }, - { - name: "campaigns", - internalType: "contract InteractionCampaign[]", - type: "address[]", - indexed: false, - }, - ], - name: "CampaignsDetached", - }, { type: "event", anonymous: false, @@ -704,6 +692,12 @@ export const contentInteractionManagerAbi = [ type: "uint256", indexed: true, }, + { + name: "interactionContract", + internalType: "contract ContentInteractionDiamond", + type: "address", + indexed: false, + }, ], name: "InteractionContractDeleted", }, @@ -734,7 +728,13 @@ export const contentInteractionManagerAbi = [ name: "contentId", internalType: "uint256", type: "uint256", - indexed: true, + indexed: false, + }, + { + name: "interactionContract", + internalType: "contract ContentInteractionDiamond", + type: "address", + indexed: false, }, ], name: "InteractionContractUpdated", diff --git a/ponder.config.ts b/ponder.config.ts index 8a35a33..229e92a 100644 --- a/ponder.config.ts +++ b/ponder.config.ts @@ -1,6 +1,11 @@ -import { createConfig } from "@ponder/core"; -import {http, parseAbiItem} from "viem"; -import {contentInteractionDiamondAbi, contentInteractionManagerAbi} from "./abis/frak-interaction-abis"; +import { createConfig, mergeAbis } from "@ponder/core"; +import { http, parseAbiItem } from "viem"; +import { + contentInteractionDiamondAbi, + contentInteractionManagerAbi, + dappStorageFacetAbi, + pressInteractionFacetAbi, +} from "./abis/frak-interaction-abis"; import { contentRegistryAbi } from "./abis/frak-registry-abis"; import { multiWebAuthNValidatorV2Abi } from "./abis/multiWebAuthNValidatorABI"; @@ -69,36 +74,42 @@ export default createConfig({ // The content registry ContentRegistry: { abi: contentRegistryAbi, - address: "0xc02209e937dB50C80AA1A280f9172163D8aC6a38", + address: "0xC110ecb55EbAa4Ea9eFC361C4bBB224A6664Ea45", network: { arbitrumSepolia: { - startBlock: 52222107, + startBlock: 54321880, }, }, }, // The interaction manager ContentInteractionManager: { abi: contentInteractionManagerAbi, - address: "0x71a54b7Edb803b0FB6c7A930794BcA13587Af21b", + address: "0x603674006fE11c38449C22bA56c40444C8e4CC5C", network: { arbitrumSepolia: { - startBlock: 52222107, + startBlock: 54321880, }, }, }, // Every content interactions ContentInteraction: { - abi: contentInteractionDiamondAbi, + abi: mergeAbis([ + contentInteractionDiamondAbi, + pressInteractionFacetAbi, + dappStorageFacetAbi, + ]), factory: { - address: "0x71a54b7Edb803b0FB6c7A930794BcA13587Af21b", - event: parseAbiItem("event InteractionContractDeployed(uint256 indexed contentId, address interactionContract)"), + address: "0x603674006fE11c38449C22bA56c40444C8e4CC5C", + event: parseAbiItem( + "event InteractionContractDeployed(uint256 indexed contentId, address interactionContract)" + ), parameter: "interactionContract", }, network: { arbitrumSepolia: { - startBlock: 52222107, + startBlock: 54321880, }, }, - } + }, }, }); diff --git a/ponder.schema.ts b/ponder.schema.ts index 7a392f0..c5e6e4a 100644 --- a/ponder.schema.ts +++ b/ponder.schema.ts @@ -65,21 +65,26 @@ export default createSchema((p) => ({ contentTypes: p.bigint(), name: p.string(), - updatedEvents: p.many("ContentUpdatedEvent.contentId"), + createTimestamp: p.bigint(), + lastUpdateTimestamp: p.bigint().optional(), + interactionContracts: p.many("ContentInteractionContract.contentId"), campaignsLink: p.many("CampaignToContent.contentId"), + administrators: p.many("ContentAdministrator.contentId"), }), - ContentUpdatedEvent: p.createTable({ - id: p.string(), - name: p.string(), - contentTypes: p.bigint(), + // Content related stuff + ContentAdministrator: p.createTable({ + id: p.hex(), contentId: p.bigint().references("Content.id"), content: p.one("contentId"), - timestamp: p.int(), + isOwner: p.boolean(), + user: p.hex(), + + createdTimestamp: p.bigint(), }), // Interaction related @@ -89,9 +94,9 @@ export default createSchema((p) => ({ contentId: p.bigint().references("Content.id"), content: p.one("contentId"), - created: p.int(), - lastUpdate: p.int().optional(), - removedTimestamp: p.int().optional(), + createdTimestamp: p.bigint(), + lastUpdateTimestamp: p.bigint().optional(), + removedTimestamp: p.bigint().optional(), }), // Campaign related @@ -114,8 +119,8 @@ export default createSchema((p) => ({ attached: p.boolean(), - attachTimestamp: p.int(), - detachTimestamp: p.int().optional(), + attachTimestamp: p.bigint(), + detachTimestamp: p.bigint().optional(), }), // Press events @@ -129,7 +134,7 @@ export default createSchema((p) => ({ type: p.enum("PressEventType"), data: p.json(), - timestamp: p.int(), + timestamp: p.bigint(), }), PressEventType: p.createEnum(["OPEN_ARTICLE", "READ_ARTICLE", "REFERRED"]), diff --git a/src/content.ts b/src/content.ts new file mode 100644 index 0000000..b257662 --- /dev/null +++ b/src/content.ts @@ -0,0 +1,55 @@ +import { ponder } from "@/generated"; +import {isAddressEqual, toHex, zeroAddress} from "viem"; + +ponder.on("ContentRegistry:ContentMinted", async ({ event, context }) => { + const { Content } = context.db; + + // Create the content + await Content.create({ + id: event.args.contentId, + data: { + name: event.args.name, + domain: event.args.domain, + contentTypes: event.args.contentTypes, + createTimestamp: event.block.timestamp, + }, + }); +}); + +ponder.on("ContentRegistry:ContentUpdated", async ({ event, context }) => { + const { Content } = context.db; + + // Update the content + await Content.update({ + id: event.args.contentId, + data: { + name: event.args.name, + contentTypes: event.args.contentTypes, + lastUpdateTimestamp: event.block.timestamp, + }, + }); +}); + +ponder.on("ContentRegistry:Transfer", async ({ event, context }) => { + const { ContentAdministrator } = context.db; + + // Delete the previous administrator + if (!isAddressEqual(event.args.from, zeroAddress)) { + await ContentAdministrator.delete({ + id: `${toHex(event.args.id)}-${event.args.from}`, + }); + } + + // Create the new administrator + await ContentAdministrator.create({ + id: `${toHex(event.args.id)}-${event.args.to}`, + data: { + isOwner: true, + contentId: event.args.id, + user: event.args.to, + createdTimestamp: event.block.timestamp, + }, + }); +}); + +// todo: manage approval diff --git a/src/interactionCampaign.ts b/src/interactionCampaign.ts new file mode 100644 index 0000000..d8c62c1 --- /dev/null +++ b/src/interactionCampaign.ts @@ -0,0 +1,59 @@ +import * as console from "node:console"; +import { ponder } from "@/generated"; +import { interactionCampaignAbi } from "../abis/frak-campaign-abis"; + +ponder.on("ContentInteraction:CampaignAttached", async ({ event, context }) => { + const { Campaign, CampaignToContent, ContentInteractionContract } = + context.db; + + // Find the interaction contract + const interactionContract = await ContentInteractionContract.findUnique({ + id: event.log.address, + }); + if (!interactionContract) { + console.error(`Interaction contract not found: ${event.log.address}`); + 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, + contentId: interactionContract.contentId, + attached: true, + attachTimestamp: event.block.timestamp, + }, + }); +}); + +ponder.on("ContentInteraction:CampaignDetached", async ({ event, context }) => { + const { CampaignToContent } = context.db; + + // Find the campaign to content and mark it as detached + await CampaignToContent.update({ + id: `${event.args.campaign}-${event.log.address}`, + data: { + attached: false, + detachTimestamp: event.block.timestamp, + }, + }); +}); diff --git a/src/interactionDeployments.ts b/src/interactionDeployments.ts new file mode 100644 index 0000000..3b82432 --- /dev/null +++ b/src/interactionDeployments.ts @@ -0,0 +1,40 @@ +import { ponder } from "@/generated"; + +ponder.on( + "ContentInteractionManager:InteractionContractDeployed", + async ({ event, context }) => { + const { ContentInteractionContract } = context.db; + + await ContentInteractionContract.create({ + id: event.args.interactionContract, + data: { + contentId: event.args.contentId, + createdTimestamp: event.block.timestamp, + }, + }); + } +); +ponder.on( + "ContentInteractionManager:InteractionContractUpdated", + async ({ event, context }) => { + const { ContentInteractionContract } = context.db; + + await ContentInteractionContract.update({ + id: event.args.interactionContract, + data: { + contentId: event.args.contentId, + lastUpdateTimestamp: event.block.timestamp, + }, + }); + } +); +ponder.on( + "ContentInteractionManager:InteractionContractDeleted", + async ({ event, context }) => { + const { ContentInteractionContract } = context.db; + + await ContentInteractionContract.delete({ + id: event.args.interactionContract, + }); + } +); diff --git a/src/pressInteractions.ts b/src/pressInteractions.ts new file mode 100644 index 0000000..a3e2515 --- /dev/null +++ b/src/pressInteractions.ts @@ -0,0 +1,48 @@ +import { ponder } from "@/generated"; + +ponder.on("ContentInteraction:ArticleRead", async ({ event, context }) => { + const { PressEvent } = context.db; + + // Insert the press event + await PressEvent.create({ + id: event.log.id, + data: { + interactionId: event.log.address, + user: event.args.user, + type: "READ_ARTICLE", + timestamp: event.block.timestamp, + data: { articleId: event.args.articleId }, + }, + }); +}); +ponder.on("ContentInteraction:ArticleOpened", async ({ event, context }) => { + const { PressEvent } = context.db; + + // Insert the press event + await PressEvent.create({ + id: event.log.id, + data: { + interactionId: event.log.address, + user: event.args.user, + type: "OPEN_ARTICLE", + timestamp: event.block.timestamp, + data: { articleId: event.args.articleId }, + }, + }); +}); + +ponder.on("ContentInteraction:UserReferred", async ({ event, context }) => { + const { PressEvent } = context.db; + + // Insert the press event + await PressEvent.create({ + id: event.log.id, + data: { + interactionId: event.log.address, + user: event.args.user, + type: "REFERRED", + timestamp: event.block.timestamp, + data: { referrer: event.args.referrer }, + }, + }); +}); From 4c94b0ae5f86dc6e7a7b3bc14d6c1445b2a0f25a Mon Sep 17 00:00:00 2001 From: KONFeature Date: Thu, 13 Jun 2024 21:15:28 +0200 Subject: [PATCH 3/3] =?UTF-8?q?=E2=9C=A8=20Fix=20content=20id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/content.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/content.ts b/src/content.ts index b257662..38b163a 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1,5 +1,12 @@ import { ponder } from "@/generated"; -import {isAddressEqual, toHex, zeroAddress} from "viem"; +import { + type Address, + type Hex, + isAddressEqual, + keccak256, + toHex, + zeroAddress, +} from "viem"; ponder.on("ContentRegistry:ContentMinted", async ({ event, context }) => { const { Content } = context.db; @@ -36,13 +43,13 @@ ponder.on("ContentRegistry:Transfer", async ({ event, context }) => { // Delete the previous administrator if (!isAddressEqual(event.args.from, zeroAddress)) { await ContentAdministrator.delete({ - id: `${toHex(event.args.id)}-${event.args.from}`, + id: contentAdministratorId(event.args.id, event.args.from), }); } // Create the new administrator await ContentAdministrator.create({ - id: `${toHex(event.args.id)}-${event.args.to}`, + id: contentAdministratorId(event.args.id, event.args.to), data: { isOwner: true, contentId: event.args.id, @@ -53,3 +60,6 @@ ponder.on("ContentRegistry:Transfer", async ({ event, context }) => { }); // todo: manage approval +function contentAdministratorId(contentId: bigint, user: Address): Hex { + return keccak256(`${toHex(contentId)}-${user}`); +}