From 4bebd44dbea8274a23c7f767def03ef5728f5314 Mon Sep 17 00:00:00 2001 From: Cho Young-Hwi Date: Tue, 17 Mar 2026 15:35:32 +0000 Subject: [PATCH] [#261] Fix royalty ABI: correct parameter order and return values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - getRoyaltyInfo: fix inputs to (wallet, reserveToken), outputs to (balance, claimed) — was (token, beneficiary) → single uint256 - claimRoyalties: pass reserve token (PLOT_TOKEN) not storyline token - ClaimRoyalties.tsx: swap args, destructure [balance] from return, use PLOT_TOKEN for both read and claim calls Co-Authored-By: Claude Opus 4.6 (1M context) --- lib/price.ts | 11 +++++++---- src/components/ClaimRoyalties.tsx | 10 +++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/price.ts b/lib/price.ts index 865eb60d..6cefd73a 100644 --- a/lib/price.ts +++ b/lib/price.ts @@ -62,16 +62,19 @@ export const mcv2BondAbi = [ name: "getRoyaltyInfo", stateMutability: "view", inputs: [ - { name: "token", type: "address" }, - { name: "beneficiary", type: "address" }, + { name: "wallet", type: "address" }, + { name: "reserveToken", type: "address" }, + ], + outputs: [ + { name: "balance", type: "uint256" }, + { name: "claimed", type: "uint256" }, ], - outputs: [{ name: "unclaimed", type: "uint256" }], }, { type: "function", name: "claimRoyalties", stateMutability: "nonpayable", - inputs: [{ name: "token", type: "address" }], + inputs: [{ name: "reserveToken", type: "address" }], outputs: [], }, priceForNextMintFunction, diff --git a/src/components/ClaimRoyalties.tsx b/src/components/ClaimRoyalties.tsx index 80c75f05..2af999a8 100644 --- a/src/components/ClaimRoyalties.tsx +++ b/src/components/ClaimRoyalties.tsx @@ -6,7 +6,7 @@ import { useQuery } from "@tanstack/react-query"; import { formatUnits, type Address } from "viem"; import { publicClient } from "../../lib/rpc"; import { mcv2BondAbi, getTokenTVL } from "../../lib/price"; -import { MCV2_BOND, IS_TESTNET, EXPLORER_URL } from "../../lib/contracts/constants"; +import { MCV2_BOND, IS_TESTNET, EXPLORER_URL, PLOT_TOKEN } from "../../lib/contracts/constants"; function formatTruncated(value: bigint, decimals: number, digits = 10): string { const raw = formatUnits(value, decimals); @@ -39,13 +39,13 @@ export function ClaimRoyalties({ tokenAddress, plotCount, beneficiary }: ClaimRo const { data: royaltyInfo, refetch } = useQuery({ queryKey: ["royalty-info", tokenAddress, beneficiary], queryFn: async () => { - const unclaimed = await publicClient.readContract({ + const [balance] = await publicClient.readContract({ address: MCV2_BOND, abi: mcv2BondAbi, functionName: "getRoyaltyInfo", - args: [tokenAddress, beneficiary], + args: [beneficiary, PLOT_TOKEN], }); - return { unclaimed }; + return { unclaimed: balance }; }, refetchInterval: 30000, }); @@ -71,7 +71,7 @@ export function ClaimRoyalties({ tokenAddress, plotCount, beneficiary }: ClaimRo address: MCV2_BOND, abi: mcv2BondAbi, functionName: "claimRoyalties", - args: [tokenAddress], + args: [PLOT_TOKEN], }); setTxHash(hash);