Skip to content

Comments

Remove SmartTransaction and CapacityManager in favor of TransactionLike#18

Merged
phroi merged 17 commits intomasterfrom
refactor/v1-01-smarttx-removal
Feb 22, 2026
Merged

Remove SmartTransaction and CapacityManager in favor of TransactionLike#18
phroi merged 17 commits intomasterfrom
refactor/v1-01-smarttx-removal

Conversation

@phroi
Copy link
Member

@phroi phroi commented Feb 22, 2026

Why

SmartTransaction and CapacityManager were thin wrappers around CCC's Transaction that added complexity without meaningful benefit. With the DAO output limit check now upstreamed into CCC core (PR #359), these abstractions are no longer needed.

Changes

  • Delete SmartTransaction and CapacityManager from @ickb/utils
  • Replace all SmartTransaction parameters with ccc.TransactionLike across all packages
  • Inline getHeader/addHeaders helpers and remove from public API
  • Consolidate 7 inline DAO output limit checks into assertDaoOutputLimit in CCC core
  • Replace local CCC patch with upstream merge ref (CCC PR #359)
  • Add noEmit to root tsconfig with per-package overrides
  • Restructure AGENTS.md with PR workflow and CCC upstream sections

phroi added 13 commits February 22, 2026 15:51
…n CCC core

- Add ErrorNervosDaoOutputLimit error class in transactionErrors.ts
- Add assertDaoOutputLimit standalone utility in transaction.ts using full Script.eq()
- Add completeFee safety net calling assertDaoOutputLimit before both return paths
- Both exported via CCC barrel (existing export * pattern)
- Add local patch mechanism to ccc-dev record/replay for deterministic builds
- Record ccc-dev pins with local patch applied
…putLimit

- DaoManager: deposit, requestWithdrawal, withdraw now async with client param
- LogicManager.deposit now async with client param
- OwnedOwnerManager: requestWithdrawal, withdraw now async with client param
- SmartTransaction.completeFee DAO check replaced with single assertDaoOutputLimit call
- Zero inline "outputs.length > 64" checks remain in packages/
- Create 01-01-SUMMARY.md with execution results
- Update STATE.md with plan completion and decisions
- Update ROADMAP.md progress (1/3 plans)
- Mark SMTX-06 complete in REQUIREMENTS.md
- Remove getHeader() function and HeaderKey type from @ickb/utils public API
- Move getHeader/HeaderKey to transaction.ts as internal (non-exported) for SmartTransaction use until Plan 03 deletion
- Move TransactionHeader interface from transaction.ts to utils.ts for downstream consumers
- Inline 5 standalone getHeader() call sites with direct CCC client calls (getTransactionWithHeader/getHeaderByNumber) with null checks
- Inline 2 tx.getHeader() instance method call sites in core/udt.ts with CCC client calls
- Replace 3 addHeaders() call sites with direct tx.headerDeps push with dedup logic
- Add 01-02-SUMMARY.md with execution results
- Update STATE.md with position, decisions, metrics
- Update ROADMAP.md with plan progress (2/3 in phase 01)
- Mark SMTX-04 requirement complete in REQUIREMENTS.md
…o TransactionLike

- All manager methods across 5 library packages accept ccc.TransactionLike and return ccc.Transaction
- Each method converts with ccc.Transaction.from(txLike) at entry
- All 8 addUdtHandlers() calls replaced with tx.addCellDeps(this.udtHandler.cellDeps)
- Inner calls to sub-managers capture returned Transaction for cascading returns
- UdtHandler interface and UdtManager class updated with TransactionLike signatures
- No consumer imports SmartTransaction (class still exists but unused externally)
…, and clean exports

- Delete packages/utils/src/transaction.ts (SmartTransaction, SmartTransactionLike, addUdtHandlers)
- Delete packages/utils/src/capacity.ts (CapacityManager, CapacityCell, addCapacities)
- Move defaultFindCellsLimit constant from capacity.ts to utils.ts
- Remove capacity.js and transaction.js barrel re-exports from index.ts
- Replace CapacityManager in SDK getCkb() with direct client.findCellsOnChain calls
- Remove CapacityManager from SDK constructor and getConfig return type
- Update faucet app: ccc.Transaction.default() + inline findCellsOnChain
- SUMMARY.md documents 2 tasks, 13 files changed, 2 deviations
- STATE.md updated: Phase 1 complete (3/3 plans), 15% progress
- ROADMAP.md updated: Phase 1 marked complete
- REQUIREMENTS.md updated: SMTX-01, SMTX-02, SMTX-05 marked complete
The DAO output limit check is now merged upstream. Replace the local
patch with a merge ref, fix local-patch index arithmetic in record/replay,
improve error cleanup to preserve local patches on failure, and skip
auto-replay during ccc:record to avoid conflicts.
Align parameter documentation with the renamed method signatures from
the SmartTransaction → TransactionLike migration.
@gemini-code-assist
Copy link

Summary of Changes

Hello @phroi, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request undertakes a significant refactoring effort by eliminating the custom SmartTransaction and CapacityManager abstractions. These components were identified as redundant given the advanced capabilities now present in the CCC core library. The changes streamline transaction construction and management across the iCKB ecosystem, enhance compatibility with upstream CCC standards, and reduce overall code complexity by adopting native CCC types and utilities.

Highlights

  • SmartTransaction and CapacityManager Removal: The SmartTransaction and CapacityManager classes have been entirely removed from @ickb/utils, simplifying the transaction management layer.
  • TransactionLike Adoption: All manager method signatures across @ickb/dao, @ickb/core, @ickb/order, and @ickb/sdk packages now accept ccc.TransactionLike instead of SmartTransaction, aligning with CCC's native conventions.
  • Consolidated DAO Output Limit Check: The 64-output NervosDAO limit check has been centralized into a new assertDaoOutputLimit utility within the CCC core, replacing scattered inline checks across the iCKB packages.
  • Inlined Header Management: The getHeader function and HeaderKey type have been removed, with all call sites now directly using CCC client calls (client.getTransactionWithHeader or client.getHeaderByNumber) and addHeaders replaced by direct tx.headerDeps pushes.
  • CCC Local Development System Enhancement: The ccc-dev system has been updated to support local patches, ensuring deterministic builds and seamless integration of CCC modifications before upstream merges.
Changelog
  • .changeset/remove-smarttx-capacitymgr.md
    • Added a new changeset entry detailing the major breaking changes across multiple packages due to the removal of SmartTransaction and CapacityManager.
  • .planning/REQUIREMENTS.md
    • Updated the status of several SMTX requirements (SMTX-01, SMTX-02, SMTX-04, SMTX-05, SMTX-06) to 'Complete' or 'x', reflecting the progress of the SmartTransaction removal phase.
  • .planning/ROADMAP.md
    • Marked Phase 1: SmartTransaction Removal as 'Complete' and updated the status of its sub-plans (01-01, 01-02, 01-03) to 'Complete'.
  • .planning/STATE.md
    • Updated the project's current position, plan completion, status, last activity, and performance metrics to reflect the completion of Phase 1 plans.
  • .planning/phases/01-ickb-utils-smarttransaction-removal/01-01-PLAN.md
    • Added a detailed plan for building the 64-output NervosDAO limit check in CCC core and replacing scattered inline checks.
  • .planning/phases/01-ickb-utils-smarttransaction-removal/01-01-SUMMARY.md
    • Added a summary report for the completion of Plan 01, detailing accomplishments, decisions, and deviations.
  • .planning/phases/01-ickb-utils-smarttransaction-removal/01-02-PLAN.md
    • Added a detailed plan for removing getHeader()/HeaderKey and inlining CCC client calls.
  • .planning/phases/01-ickb-utils-smarttransaction-removal/01-02-SUMMARY.md
    • Added a summary report for the completion of Plan 02, detailing accomplishments, decisions, and deviations.
  • .planning/phases/01-ickb-utils-smarttransaction-removal/01-03-PLAN.md
    • Added a detailed plan for deleting SmartTransaction and CapacityManager, updating method signatures, and cleaning exports.
  • .planning/phases/01-ickb-utils-smarttransaction-removal/01-03-SUMMARY.md
    • Added a summary report for the completion of Plan 03, detailing accomplishments, decisions, and deviations.
  • .planning/phases/01-ickb-utils-smarttransaction-removal/01-RESEARCH.md
    • Added a comprehensive research document outlining the strategy, patterns, pitfalls, and detailed inventory for SmartTransaction removal.
  • .planning/phases/01-ickb-utils-smarttransaction-removal/01-VERIFICATION.md
    • Added a verification report confirming the successful completion of Phase 1 requirements and artifacts.
  • .pnpmfile.cjs
    • Modified the pnpmfile to skip auto-replay of CCC pins when ccc:record is running, preventing conflicts during recording.
  • AGENTS.md
    • Updated the PR workflow section to include pnpm changeset and restructured the document for clarity, moving workflow details under a dedicated heading.
  • apps/bot/tsconfig.json
    • Configured noEmit to false in compiler options.
  • apps/faucet/src/main.ts
    • Removed imports for CapacityManager, collect, and SmartTransaction, and updated the logic to use ccc.Transaction.default() and client.findCellsOnChain directly for capacity management.
  • apps/faucet/tsconfig.json
    • Configured noEmit to false in compiler options.
  • apps/sampler/tsconfig.json
    • Configured noEmit to false in compiler options.
  • apps/tester/tsconfig.json
    • Configured noEmit to false in compiler options.
  • ccc-dev/README.md
    • Updated the documentation for pins/ format to include local patches and clarified the diagnostic filtering mechanism.
  • ccc-dev/pins/HEAD
    • Updated the HEAD SHA to reflect the latest state of the CCC pins after applying changes.
  • ccc-dev/pins/REFS
    • Added a new merge ref for PR #359, indicating the integration of upstream changes.
  • ccc-dev/pins/resolutions/3/packages/core/src/ckb/transactionErrors.ts
    • Added a new file containing the ErrorNervosDaoOutputLimit class as part of the CCC core changes.
  • ccc-dev/pins/resolutions/3/vitest.config.mts
    • Renamed the vitest config file from ccc-dev/pins/resolutions/2/vitest.config.mts.
  • ccc-dev/record.sh
    • Modified the script to preserve and apply local patches during recording, ensuring deterministic builds.
  • ccc-dev/replay.sh
    • Modified the script to apply local patches after merges, ensuring deterministic replay of CCC modifications.
  • package.json
    • Updated the ccc:record script to include PR #359 in the merge sequence.
  • packages/core/src/cells.ts
    • Removed the getHeader utility import and inlined its functionality using client.getTransactionWithHeader with null checks.
  • packages/core/src/logic.ts
    • Refactored deposit and completeDeposit methods to accept ccc.TransactionLike, convert to ccc.Transaction, return ccc.Transaction, and replaced tx.addUdtHandlers with tx.addCellDeps.
  • packages/core/src/owned_owner.ts
    • Refactored requestWithdrawal and withdraw methods to accept ccc.TransactionLike, convert to ccc.Transaction, return ccc.Transaction, and replaced tx.addUdtHandlers with tx.addCellDeps.
  • packages/core/src/udt.ts
    • Updated getInputsUdtBalance to accept ccc.TransactionLike and inlined tx.getHeader calls with client.getTransactionWithHeader.
  • packages/dao/src/cells.ts
    • Removed the getHeader utility import and inlined its functionality using client.getHeaderByNumber and client.getTransactionWithHeader with null checks.
  • packages/dao/src/dao.ts
    • Refactored deposit, requestWithdrawal, and withdraw methods to accept ccc.TransactionLike, convert to ccc.Transaction, return ccc.Transaction, and replaced tx.addHeaders with direct tx.headerDeps.push with deduplication.
  • packages/order/src/order.ts
    • Refactored mint, addMatch, and melt methods to accept ccc.TransactionLike, convert to ccc.Transaction, return ccc.Transaction, and replaced tx.addUdtHandlers with tx.addCellDeps.
  • packages/sdk/src/constants.ts
    • Removed CapacityManager from the getConfig return type and its instantiation.
  • packages/sdk/src/sdk.ts
    • Removed CapacityManager and SmartTransaction imports, updated the constructor, and replaced this.capacity.findCapacities with direct client.findCellsOnChain calls.
  • packages/utils/src/capacity.ts
    • Deleted the capacity.ts file, removing the CapacityManager class.
  • packages/utils/src/index.ts
    • Removed exports for capacity.js and transaction.js.
  • packages/utils/src/transaction.ts
    • Deleted the transaction.ts file, removing the SmartTransaction class.
  • packages/utils/src/udt.ts
    • Updated UdtHandler interface and UdtManager methods to accept ccc.TransactionLike and convert to ccc.Transaction.
  • packages/utils/src/utils.ts
    • Moved defaultFindCellsLimit and TransactionHeader interface to this file, and removed getHeader function and HeaderKey type.
  • pnpm-lock.yaml
    • Updated various package dependencies, including @eslint/js, eslint, glob, minimatch, path-scurry, rollup, typescript-eslint, and vite.
  • tsconfig.json
    • Configured noEmit to true in the root compiler options.
Activity
  • The pull request implements Phase 1 of the roadmap, focusing on SmartTransaction removal, which has been completed across three distinct plans.
  • Plan 01 involved building the ErrorNervosDaoOutputLimit class and assertDaoOutputLimit utility in CCC core, and replacing all scattered DAO checks. This plan was completed in approximately 30 minutes.
  • Plan 02 focused on removing getHeader()/HeaderKey and inlining CCC client calls, as well as replacing addHeaders() with direct tx.headerDeps pushes. This plan was completed in approximately 6 minutes.
  • Plan 03 completed the removal of SmartTransaction and CapacityManager classes, updated all method signatures to ccc.TransactionLike, and replaced addUdtHandlers() calls. This plan was completed in approximately 16 minutes.
  • A comprehensive research document (01-RESEARCH.md) was added, detailing the strategy, patterns, and potential pitfalls for the SmartTransaction removal.
  • A verification report (01-VERIFICATION.md) was generated, confirming that all Phase 1 requirements and artifacts were successfully met, and the build passed cleanly.
  • The ccc-dev system was enhanced to support local patches for deterministic builds of CCC modifications, addressing a blocking issue identified during Task 1 of Plan 01.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully removes the SmartTransaction and CapacityManager abstractions, aligning the codebase with standard CCC (ckb-ccc) patterns. The transition to ccc.TransactionLike for method parameters and ccc.Transaction for return values is thorough and follows the established conventions of the CCC ecosystem. The consolidation of DAO output limit checks into a centralized utility in CCC core is a significant maintainability improvement. The build system enhancements for managing local CCC patches also provide a robust way to handle upstream dependencies during development.

@phroi phroi force-pushed the refactor/v1-01-smarttx-removal branch from 4342ea7 to d7b2ffa Compare February 22, 2026 22:20
@phroi
Copy link
Member Author

phroi commented Feb 22, 2026

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This is a substantial and well-executed refactoring that successfully removes the SmartTransaction and CapacityManager abstractions. The changes are consistent across all packages, replacing custom implementations with the upstream ccc library's features, which significantly simplifies the codebase. The migration to the TransactionLike pattern, the inlining of helper functions, and the centralization of the DAO output limit check are all implemented correctly. The documentation and project management files have also been updated to reflect these significant changes. I found no issues in the implementation.

@phroi phroi force-pushed the refactor/v1-01-smarttx-removal branch 2 times, most recently from ca2c98b to 3972f5e Compare February 22, 2026 22:43
Reorganize into numbered PR workflow steps, add CCC upstream PR
instructions, and sync reference repos description with CLAUDE.md.
Set noEmit: true at the root level so type-checking-only invocations
(tsgo, IDE) don't accidentally emit files. Packages and apps that
need to emit override with noEmit: false in their own tsconfig.
Also fix review findings:
- Remove redundant assertDaoOutputLimit in OwnedOwnerManager.withdraw
  (already called inside daoManager.withdraw; only inputs added after)
- Remove dead options reassignment in OwnedOwnerManager.withdraw
- Return ccc.Transaction from UdtHandler.completeUdt to avoid silent
  mutation loss when callers pass a plain TransactionLike object
@phroi phroi force-pushed the refactor/v1-01-smarttx-removal branch from 3972f5e to 3126894 Compare February 22, 2026 23:40
@phroi
Copy link
Member Author

phroi commented Feb 22, 2026

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully removes the SmartTransaction and CapacityManager abstractions in favor of the native ccc.TransactionLike and ccc.Transaction types from the CCC core library. The changes include inlining header management, consolidating DAO output limit checks into a centralized utility in CCC core, and updating method signatures across all packages to follow the CCC convention of accepting TransactionLike and returning Transaction. The build configuration has also been improved with noEmit at the root level. Overall, the refactoring significantly simplifies the codebase and aligns it better with the upstream library.

@phroi
Copy link
Member Author

phroi commented Feb 22, 2026

LGTM

Phroi %235

@phroi phroi merged commit 927b0eb into master Feb 22, 2026
2 checks 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.

1 participant