Skip to content

[#321] Fix SDK royalty ABI/client and web app MCV2 ABI accuracy#326

Merged
realproject7 merged 1 commit intomainfrom
task/321-fix-sdk-royalty-abi
Mar 18, 2026
Merged

[#321] Fix SDK royalty ABI/client and web app MCV2 ABI accuracy#326
realproject7 merged 1 commit intomainfrom
task/321-fix-sdk-royalty-abi

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • SDK ABI (packages/sdk/src/abi.ts): Fixed getRoyaltyInfo inputs to (wallet, reserveToken) with outputs (balance, claimed); renamed claimRoyalties input to reserveToken
  • SDK client (packages/sdk/src/client.ts): getRoyaltyInfo() now passes (beneficiary, reserveToken) in correct order and returns both balance and claimed; claimRoyalties() accepts reserve token address
  • CLI claim (packages/cli/src/commands/claim.ts): Passes reserveToken (already available from tokenBond()) to SDK methods instead of storyline token
  • CLI status (packages/cli/src/commands/status.ts): Hoisted bondReserveToken for royalty info call
  • Web app ABI (lib/price.ts): Added missing royalty output to getReserveForToken/getRefundForTokens; added uint256 return to mint/burn
  • TradingWidget + PriceChart: Extract first tuple element from updated ABI return types

Fixes #321

Test plan

  • npm run build passes
  • npm run typecheck passes
  • Verify trading estimates still display correctly (TradingWidget extracts [0] from tuple)
  • Verify CLI claim command works with reserve token
  • Verify CLI status command displays royalty info

SDK fixes:
- getRoyaltyInfo: inputs corrected to (wallet, reserveToken), outputs
  to (balance, claimed) matching MCV2_Royalty contract
- claimRoyalties: input renamed to reserveToken; client now accepts
  reserve token address instead of storyline token
- RoyaltyInfo type: unclaimed → balance + claimed fields

CLI fixes:
- claim command: passes reserveToken to getRoyaltyInfo/claimRoyalties
- status command: passes bondReserveToken to getRoyaltyInfo

Web app ABI fixes (lib/price.ts):
- getReserveForToken: outputs now include royalty field
- getRefundForTokens: outputs now include royalty field
- mint/burn: outputs now include uint256 return value
- TradingWidget/PriceChart: extract first tuple element from
  getReserveForToken/getRefundForTokens results

Fixes #321

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T2b APPROVE

Verified all changes against IMCV2_Bond.sol and MCV2_Royalty.sol contract source:

SDK ABI (packages/sdk/src/abi.ts):

  • getRoyaltyInfo: inputs (wallet, reserveToken), outputs (balance, claimed) — matches MCV2_Royalty ✅
  • claimRoyalties: input reserveToken — matches contract ✅

SDK client (packages/sdk/src/client.ts):

  • getRoyaltyInfo(beneficiary, reserveToken) arg order matches ABI ✅
  • Returns { balance, claimed } from tuple destructure ✅
  • claimRoyalties(reserveToken) accepts reserve token ✅

CLI (claim.ts, status.ts):

  • Both commands pass reserveToken (from tokenBond()) instead of storyline token ✅
  • Use info.balance instead of info.unclaimed

Web app ABI (lib/price.ts):

  • getReserveForToken/getRefundForTokens: added royalty output ✅
  • mint/burn: added uint256 return ✅
  • Royalty functions already correct in this file ✅

Components (TradingWidget.tsx, PriceChart.tsx):

  • Both extract [0] from new tuple return types — trading estimates preserved ✅

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Summary

This PR fixes the SDK royalty ABI/client mismatch and updates the web app MCV2 ABI outputs to match the contract while preserving the existing trading estimate behavior. The changes are consistent with issue #321 and the checked IMCV2_Bond.sol interface.

Findings

  • [low] packages/sdk/src/abi.ts, packages/sdk/src/client.ts, and the CLI call sites now consistently use (beneficiary, reserveToken) for getRoyaltyInfo and reserveToken for claimRoyalties.
    • File: packages/sdk/src/client.ts:503
    • Suggestion: None.
  • [low] The lib/price.ts tuple output corrections are handled safely at the UI call sites by extracting the first tuple element, so price/refund estimates continue to use the reserve/refund amount.
    • File: src/components/TradingWidget.tsx:68
    • Suggestion: None.

Decision

Approve. The ABI shapes now match the contract, CLI royalty flows pass the reserve token correctly, and local npm run build plus npm run typecheck both pass.

@realproject7 realproject7 merged commit 8d4c2d0 into main Mar 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[#320] Fix SDK royalty ABI and client — wrong getRoyaltyInfo/claimRoyalties

2 participants