Skip to content

Commit

Permalink
Merge branch 'feat/update'
Browse files Browse the repository at this point in the history
  • Loading branch information
KONFeature committed Oct 7, 2024
2 parents f4661bb + f05a861 commit 325c8c0
Show file tree
Hide file tree
Showing 10 changed files with 1,549 additions and 423 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"typecheck": "tsc"
},
"devDependencies": {
"@biomejs/biome": "1.8.3",
"@biomejs/biome": "1.9.3",
"@types/aws-lambda": "8.10.138",
"@types/node": "^22.5.4",
"aws-cdk-lib": "2.142.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/erpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
"typecheck": "tsc"
},
"devDependencies": {
"@biomejs/biome": "1.8.3",
"@biomejs/biome": "1.9.3",
"@konfeature/erpc-config-generator": "0.0.12",
"@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",
"viem": "^2.21.6"
"viem": "^2.21.19"
},
"engines": {
"node": ">=18.14"
Expand Down
18 changes: 9 additions & 9 deletions packages/ponder/abis/addresses.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"campaignBankFactory": "0x383922F9ab2Ee7b61Cd2BFF1DEB782733eDc246F",
"campaignFactory": "0xe621E3E82bEAD4a10f2f2e95f6297b659Fc7525D",
"facetFactory": "0x69e37f52E1A2Fff5026b212b32207d3E0Cdceb58",
"mUSDToken": "0x56039fa1a804F614eBD714139F29a3ff4DB57ad6",
"productAdministratorRegistry": "0x932fe8a2dd6f8d1009FB916f0F1FEB85cB18316E",
"productInteractionManager": "0x089369aD02bc21459fE4101151fD6D2bBD7FA08A",
"productRegistry": "0x5752E0FB600C59E140CDAfDA7AC8933774c19280",
"purchaseOracle": "0x334C29312Db5cc0e63cD842ACb9D17326e8a254A",
"referralRegistry": "0x80B0385e97263A60BafB554B0C4152261D45785A"
"campaignBankFactory": "0x00000000003604CF2d09f4Aa3B878843A765015d",
"campaignFactory": "0x0000000000278e0EFbC5968020A798AaB1571E5c",
"facetFactory": "0x000000000068C43436b8970Ee8791718f50b9643",
"mUSDToken": "0x43838DCb58a61325eC5F31FD70aB8cd3540733d1",
"productAdministratorRegistry": "0x0000000000000823EaD12075a50A2a6520966e5c",
"productInteractionManager": "0x0000000000009720dc2B0D893f7Ec2a878d21AeC",
"productRegistry": "0x9100000000290000D9a49572110030ba00E0F40b",
"purchaseOracle": "0x0000EC17000000e783CA00Ee06890000114C100d",
"referralRegistry": "0x5439e7b27500f7000A6DCD00006D000082510000"
}
10 changes: 0 additions & 10 deletions packages/ponder/abis/campaignAbis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,6 @@ export const campaignFactoryAbi = [
internalType: "contract ProductAdministratorRegistry",
type: "address",
},
{
name: "_frakCampaignWallet",
internalType: "address",
type: "address",
},
],
stateMutability: "nonpayable",
},
Expand Down Expand Up @@ -491,11 +486,6 @@ export const referralCampaignAbi = [
internalType: "contract ProductAdministratorRegistry",
type: "address",
},
{
name: "_frakCampaignWallet",
internalType: "address",
type: "address",
},
{
name: "_interaction",
internalType: "contract ProductInteractionDiamond",
Expand Down
50 changes: 35 additions & 15 deletions packages/ponder/abis/registryAbis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,13 @@ export const productRegistryAbi = [
internalType: "ProductTypes",
type: "uint256",
},
{ name: "name", internalType: "string", type: "string" },
{ name: "name", internalType: "bytes32", type: "bytes32" },
{ name: "domain", internalType: "string", type: "string" },
{
name: "customMetadataUrl",
internalType: "string",
type: "string",
},
],
},
],
Expand Down Expand Up @@ -281,15 +286,6 @@ export const productRegistryAbi = [
outputs: [{ name: "result", internalType: "bool", type: "bool" }],
stateMutability: "view",
},
{
type: "function",
inputs: [
{ name: "_productId", internalType: "uint256", type: "uint256" },
],
name: "isExistingProduct",
outputs: [{ name: "", internalType: "bool", type: "bool" }],
stateMutability: "view",
},
{
type: "function",
inputs: [
Expand All @@ -298,7 +294,7 @@ export const productRegistryAbi = [
internalType: "ProductTypes",
type: "uint256",
},
{ name: "_name", internalType: "string", type: "string" },
{ name: "_name", internalType: "bytes32", type: "bytes32" },
{ name: "_domain", internalType: "string", type: "string" },
{ name: "_owner", internalType: "address", type: "address" },
],
Expand Down Expand Up @@ -407,6 +403,19 @@ export const productRegistryAbi = [
outputs: [],
stateMutability: "nonpayable",
},
{
type: "function",
inputs: [
{
name: "_baseMetadataUrl",
internalType: "string",
type: "string",
},
],
name: "setMetadataUrl",
outputs: [],
stateMutability: "nonpayable",
},
{
type: "function",
inputs: [
Expand All @@ -428,7 +437,7 @@ export const productRegistryAbi = [
inputs: [{ name: "tokenId", internalType: "uint256", type: "uint256" }],
name: "tokenURI",
outputs: [{ name: "", internalType: "string", type: "string" }],
stateMutability: "pure",
stateMutability: "view",
},
{
type: "function",
Expand Down Expand Up @@ -459,7 +468,12 @@ export const productRegistryAbi = [
internalType: "ProductTypes",
type: "uint256",
},
{ name: "_name", internalType: "string", type: "string" },
{ name: "_name", internalType: "bytes32", type: "bytes32" },
{
name: "_customMetadataUrl",
internalType: "string",
type: "string",
},
],
name: "updateMetadata",
outputs: [],
Expand Down Expand Up @@ -584,8 +598,8 @@ export const productRegistryAbi = [
},
{
name: "name",
internalType: "string",
type: "string",
internalType: "bytes32",
type: "bytes32",
indexed: false,
},
],
Expand All @@ -609,6 +623,12 @@ export const productRegistryAbi = [
},
{
name: "name",
internalType: "bytes32",
type: "bytes32",
indexed: false,
},
{
name: "customMetadataUrl",
internalType: "string",
type: "string",
indexed: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/ponder/config/config-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default createEnvConfig({
pgDatabase: "ponder_dev",
network: {
chainId: 421614,
deploymentBlock: 75793399,
deploymentBlock: 86607902,
},
networkKey: "arbitrumSepolia",
});
14 changes: 8 additions & 6 deletions packages/ponder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"scripts": {
"codegen": "ponder --config config/config-local.ts codegen",
"dev": "ponder --config config/config-dev.ts dev",
"dev": "ponder --config config/config-local.ts dev",
"format": "biome check --write .",
"format:check": "biome check .",
"lint": "biome lint .",
Expand All @@ -16,20 +16,22 @@
"typecheck": "tsc"
},
"dependencies": {
"@ponder/core": "^0.6.3",
"@ponder/core": "^0.6.7",
"drizzle-orm": "^0.31.4",
"hono": "^4.5.8",
"viem": "^2.21.6"
"hono": "^4.6.3",
"viem": "^2.21.19"
},
"devDependencies": {
"@biomejs/biome": "1.8.3",
"@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"
},
"trustedDependencies": ["better_sqlite3"],
"trustedDependencies": [
"better_sqlite3"
],
"engines": {
"node": ">=18.14"
},
Expand Down
2 changes: 2 additions & 0 deletions packages/ponder/ponder.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export default createSchema((p) => ({
createTimestamp: p.bigint(),
lastUpdateTimestamp: p.bigint().optional(),

metadataUrl: p.string().optional(),

interactionContracts: p.many("ProductInteractionContract.productId"),

campaigns: p.many("Campaign.productId"),
Expand Down
22 changes: 20 additions & 2 deletions packages/ponder/src/product.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
import { ponder } from "@/generated";
import { productRegistryAbi } from "../abis/registryAbis";

ponder.on("ProductRegistry:ProductMinted", async ({ event, context }) => {
const { Product } = context.db;

// Get the metadata url
const metadataUrl = await context.client.readContract({
abi: productRegistryAbi,
functionName: "tokenURI",
address: context.contracts.ProductRegistry.address,
args: [event.args.productId],
});

// Create the product
await Product.create({
id: event.args.productId,
Expand All @@ -11,20 +20,29 @@ ponder.on("ProductRegistry:ProductMinted", async ({ event, context }) => {
domain: event.args.domain,
productTypes: event.args.productTypes,
createTimestamp: event.block.timestamp,
metadataUrl,
},
});
});

ponder.on("ProductRegistry:ProductUpdated", async ({ event, context }) => {
const { Product } = context.db;

let metadataUrl = undefined;

// Update the metadata url if needed
if (event.args.customMetadataUrl.length > 0) {
metadataUrl = event.args.customMetadataUrl;
}

// Update the product
await Product.update({
id: event.args.productId,
data: {
data: ({ current }) => ({
name: event.args.name,
productTypes: event.args.productTypes,
lastUpdateTimestamp: event.block.timestamp,
},
metadataUrl: metadataUrl ?? current.metadataUrl,
}),
});
});
Loading

0 comments on commit 325c8c0

Please sign in to comment.