From 1c3e82313baecee7f0a1c6a9310e64543877cf94 Mon Sep 17 00:00:00 2001 From: Cho Young-Hwi Date: Tue, 31 Mar 2026 09:20:59 +0100 Subject: [PATCH] [#661] Fix hardcoded Sepolia addresses in claim and status commands claim.ts and status.ts imported MCV2_BOND_ADDRESS and STORY_FACTORY_ADDRESS directly from constants, which always resolved to Sepolia addresses regardless of the configured chain. Fix: expose storyFactory and mcv2Bond as public readonly on the PlotLink client (which already resolves them based on chainId), and use client.mcv2Bond / client.storyFactory in both commands. Fixes realproject7/plotlink#661 Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/cli/src/commands/claim.ts | 4 ++-- packages/cli/src/commands/status.ts | 6 +++--- packages/cli/src/sdk/client.ts | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/cli/src/commands/claim.ts b/packages/cli/src/commands/claim.ts index 6911576a..97d79f9a 100644 --- a/packages/cli/src/commands/claim.ts +++ b/packages/cli/src/commands/claim.ts @@ -1,6 +1,6 @@ import type { Command } from "commander"; import { type Address, erc20Abi, formatUnits, isAddress } from "viem"; -import { MCV2_BOND_ADDRESS, mcv2BondAbi } from "../sdk/index.js"; +import { mcv2BondAbi } from "../sdk/index.js"; import { buildClient } from "../sdk.js"; export function registerClaim(program: Command): void { @@ -20,7 +20,7 @@ export function registerClaim(program: Command): void { // Fetch bond data (creator = beneficiary, reserve token for display) console.log("Checking royalties..."); const bond = await client.publicClient.readContract({ - address: MCV2_BOND_ADDRESS, + address: client.mcv2Bond, abi: mcv2BondAbi, functionName: "tokenBond", args: [tokenAddress], diff --git a/packages/cli/src/commands/status.ts b/packages/cli/src/commands/status.ts index 0f6a738e..a9a7b690 100644 --- a/packages/cli/src/commands/status.ts +++ b/packages/cli/src/commands/status.ts @@ -1,7 +1,7 @@ import type { Command } from "commander"; import { createClient } from "@supabase/supabase-js"; import { type Address, erc20Abi, formatUnits } from "viem"; -import { MCV2_BOND_ADDRESS, mcv2BondAbi, STORY_FACTORY_ADDRESS } from "../sdk/index.js"; +import { mcv2BondAbi } from "../sdk/index.js"; import { buildClient } from "../sdk.js"; import { loadConfig } from "../config.js"; @@ -45,7 +45,7 @@ export function registerStatus(program: Command): void { .from("storylines") .select("plot_count, last_plot_time, has_deadline, sunset, writer_type, block_timestamp") .eq("storyline_id", Number(storylineId)) - .eq("contract_address", STORY_FACTORY_ADDRESS.toLowerCase()) + .eq("contract_address", client.storyFactory.toLowerCase()) .single(); dbRow = data; } @@ -59,7 +59,7 @@ export function registerStatus(program: Command): void { let bondReserveToken: Address | null = null; try { const bond = await client.publicClient.readContract({ - address: MCV2_BOND_ADDRESS, + address: client.mcv2Bond, abi: mcv2BondAbi, functionName: "tokenBond", args: [info.tokenAddress], diff --git a/packages/cli/src/sdk/client.ts b/packages/cli/src/sdk/client.ts index 64b59b0c..224e7db5 100644 --- a/packages/cli/src/sdk/client.ts +++ b/packages/cli/src/sdk/client.ts @@ -149,8 +149,8 @@ export class PlotLink { readonly walletClient: WalletClient; readonly address: Address; - private readonly storyFactory: Address; - private readonly mcv2Bond: Address; + readonly storyFactory: Address; + readonly mcv2Bond: Address; private readonly erc8004Registry: Address; private readonly filebase: FilebaseConfig | undefined; private readonly chain: Chain;