From e11a22192558732dbc9fbca184e5a80cadfa47c7 Mon Sep 17 00:00:00 2001 From: Cho Young-Hwi Date: Wed, 25 Mar 2026 12:01:07 +0000 Subject: [PATCH 1/3] [#539] Update StoryFactory to new v4 contract address MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - StoryFactory mainnet: 0x337c5b96... → 0x92c3bd44... - DEPLOYMENT_BLOCK: 43609150 → 43824790 (v4 deploy block) - Updated in lib/contracts/constants.ts and packages/sdk/src/constants.ts - .env.local updated locally (gitignored) - Bump version to 0.1.11 Fixes #539 Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/contracts/constants.ts | 6 +++--- package.json | 2 +- packages/sdk/src/constants.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/contracts/constants.ts b/lib/contracts/constants.ts index 0caf378b..69d4db8b 100644 --- a/lib/contracts/constants.ts +++ b/lib/contracts/constants.ts @@ -24,14 +24,14 @@ export const EXPLORER_URL = IS_TESTNET // PlotLink contracts // --------------------------------------------------------------------------- -/** Deployment block for the v3 StoryFactory on Base mainnet */ -export const DEPLOYMENT_BLOCK = BigInt(43_609_150); +/** Deployment block for the v4 StoryFactory (J-curve + real PLOT) on Base mainnet */ +export const DEPLOYMENT_BLOCK = BigInt(43_824_790); /** StoryFactory — storyline + plot management */ export const STORY_FACTORY = (process.env.NEXT_PUBLIC_CONTRACT_ADDRESS ?? (IS_TESTNET ? "0xfa5489b6710Ba2f8406b37fA8f8c3018e51FA229" - : "0x337c5b96f03fB335b433291695A4171fd5dED8B0")) as `0x${string}`; + : "0x92c3bd44fda84e632c3c3cb31387d0c0c1de618d")) as `0x${string}`; /** ZapPlotLinkV2 — one-click buy (ETH/USDC/HUNT -> PLOT -> storyline token via Uniswap V4 + MCV2) * Testnet: disabled (V1 contract incompatible with V2 ABI) */ diff --git a/package.json b/package.json index 5b3c0e19..8cd1fd63 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plotlink", - "version": "0.1.10", + "version": "0.1.11", "private": true, "workspaces": [ "packages/*" diff --git a/packages/sdk/src/constants.ts b/packages/sdk/src/constants.ts index 39869a6f..bb40033d 100644 --- a/packages/sdk/src/constants.ts +++ b/packages/sdk/src/constants.ts @@ -26,7 +26,7 @@ export const DEPLOYMENT_BLOCK = BigInt(20_000_000); * Deployment block for PlotLink contracts on Base mainnet. * Used as the default fromBlock for mainnet event log queries. */ -export const DEPLOYMENT_BLOCK_MAINNET = BigInt(43_609_150); +export const DEPLOYMENT_BLOCK_MAINNET = BigInt(43_824_790); /** Supported chain IDs for the PlotLink SDK. */ export const SUPPORTED_CHAIN_IDS = new Set([BASE_SEPOLIA_CHAIN_ID, BASE_MAINNET_CHAIN_ID]); @@ -41,7 +41,7 @@ export const STORY_FACTORY_ADDRESS = /** StoryFactory — storyline + plot management (Base mainnet). */ export const STORY_FACTORY_MAINNET_ADDRESS = - "0x337c5b96f03fB335b433291695A4171fd5dED8B0" as const; + "0x92c3bd44fda84e632c3c3cb31387d0c0c1de618d" as const; /** MCV2_Bond — bonding curve trading (Base Sepolia). */ export const MCV2_BOND_ADDRESS = From dd4c880c4f3e7d268b5e136c473ab0e4afc7f247 Mon Sep 17 00:00:00 2001 From: Cho Young-Hwi Date: Wed, 25 Mar 2026 12:03:55 +0000 Subject: [PATCH 2/3] [#539] Fix: backfill cron falls back to DEPLOYMENT_BLOCK instead of block 0 When no cursor exists (new contract deployment), start scanning from DEPLOYMENT_BLOCK instead of block 0 to avoid scanning irrelevant blocks. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/app/api/cron/backfill/route.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/api/cron/backfill/route.ts b/src/app/api/cron/backfill/route.ts index 72e34282..955a5cc9 100644 --- a/src/app/api/cron/backfill/route.ts +++ b/src/app/api/cron/backfill/route.ts @@ -3,7 +3,7 @@ import { decodeEventLog, type Log } from "viem"; import { publicClient } from "../../../../../lib/rpc"; import { createServerClient } from "../../../../../lib/supabase"; import { storyFactoryAbi } from "../../../../../lib/contracts/abi"; -import { STORY_FACTORY } from "../../../../../lib/contracts/constants"; +import { STORY_FACTORY, DEPLOYMENT_BLOCK } from "../../../../../lib/contracts/constants"; import { hashContent } from "../../../../../lib/content"; import { detectWriterType } from "../../../../../lib/contracts/erc8004"; import { reconcileStorylinePlotCount } from "../../../../../lib/reconcile"; @@ -106,8 +106,8 @@ export async function GET(req: Request) { .single(); const lastBlock = cursor?.last_block ? BigInt(cursor.last_block) : BigInt(0); - // Start from block after last processed; cap toBlock to limit scan per run - const fromBlock = lastBlock > BigInt(0) ? lastBlock + BigInt(1) : BigInt(0); + // Start from block after last processed; fall back to DEPLOYMENT_BLOCK for new contracts + const fromBlock = lastBlock > BigInt(0) ? lastBlock + BigInt(1) : DEPLOYMENT_BLOCK; if (fromBlock > currentBlock) { return NextResponse.json({ skipped: true, reason: "Already up to date" }); From 741615177ee9c56ea6fea87e2bdc895451c88b69 Mon Sep 17 00:00:00 2001 From: Cho Young-Hwi Date: Wed, 25 Mar 2026 12:05:32 +0000 Subject: [PATCH 3/3] [#539] Add migration to reset backfill_cursor for v4 StoryFactory Resets cursor to block 43824789 (one before v4 deploy block) so the cron picks up all events from the new contract, even if the old cursor was already past that block. Co-Authored-By: Claude Opus 4.6 (1M context) --- supabase/migrations/00023_reset_backfill_cursor_v4.sql | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 supabase/migrations/00023_reset_backfill_cursor_v4.sql diff --git a/supabase/migrations/00023_reset_backfill_cursor_v4.sql b/supabase/migrations/00023_reset_backfill_cursor_v4.sql new file mode 100644 index 00000000..2b2374ee --- /dev/null +++ b/supabase/migrations/00023_reset_backfill_cursor_v4.sql @@ -0,0 +1,4 @@ +-- [#539] Reset backfill_cursor for StoryFactory v4 (J-curve + real PLOT) +-- New contract deployed at block 43824790 +-- Old cursor may be past this block, so reset to pick up new factory events +UPDATE backfill_cursor SET last_block = 43824789 WHERE id = 1;