Skip to content

Commit 5f56518

Browse files
committed
docs(phase-03): CCC Udt integration investigation
Decision: subclass CCC Udt as IckbUdt, overriding infoFrom() for multi-representation balance (xUDT + receipts + deposits). Header access via client.getTransactionWithHeader(). Conservation law enforced on-chain, not in infoFrom.
1 parent 14e1c87 commit 5f56518

12 files changed

Lines changed: 2444 additions & 34 deletions

File tree

.planning/REQUIREMENTS.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ Requirements for initial milestone. Each maps to roadmap phases.
3030

3131
### CCC Udt Integration
3232

33-
- [ ] **UDT-01**: Feasibility assessment completed: can `IckbUdt extends udt.Udt` override `infoFrom()` or `getInputsInfo()`/`getOutputsInfo()` to account for receipt cells and deposit cells alongside xUDT cells
34-
- [ ] **UDT-02**: Header access pattern for receipt value calculation is designed -- determine whether `client.getCellWithHeader()`, `client.getHeaderByTxHash()`, or direct CCC client calls are used within the Udt override (`getHeader()` utility removed in Phase 1)
35-
- [ ] **UDT-03**: Decision documented: subclass CCC `Udt` vs. keep custom `UdtHandler` interface vs. hybrid approach
33+
- [x] **UDT-01**: Feasibility assessment completed: can `IckbUdt extends udt.Udt` override `infoFrom()` or `getInputsInfo()`/`getOutputsInfo()` to account for receipt cells and deposit cells alongside xUDT cells
34+
- [x] **UDT-02**: Header access pattern for receipt value calculation is designed -- determine whether `client.getCellWithHeader()`, `client.getTransactionWithHeader()`, or direct CCC client calls are used within the Udt override (`getHeader()` utility removed in Phase 1)
35+
- [x] **UDT-03**: Decision documented: subclass CCC `Udt` vs. keep custom `UdtHandler` interface vs. hybrid approach
3636
- [ ] **UDT-04**: If subclassing is viable, `IckbUdt` class is implemented in `@ickb/core` with multi-representation balance calculation
3737
- [ ] **UDT-05**: If subclassing is not viable, `IckbUdtManager` is refactored to work with plain `ccc.Transaction` (no SmartTransaction dependency) while maintaining a compatible interface
3838

@@ -86,7 +86,7 @@ Which phases cover which requirements. Updated during roadmap creation.
8686
| SMTX-03 | Phase 6 | Pending | |
8787
| SMTX-04 | Phase 1 | Complete | getHeader()/HeaderKey removed, CCC client calls inlined |
8888
| SMTX-05 | Phase 1, 4, 5 | Complete | addUdtHandlers() replaced with tx.addCellDeps(udtHandler.cellDeps) (01-03); UdtHandler/UdtManager replacement deferred to Phase 4-5 |
89-
| SMTX-06 | Phase 1 | Complete | DAO check contributed to CCC core via ccc-dev/ (01-01) |
89+
| SMTX-06 | Phase 1 | Complete | DAO check contributed to CCC core via ccc-fork/ (01-01) |
9090
| SMTX-07 | Phase 5 | Pending | |
9191
| SMTX-08 | Phase 6 | Pending | |
9292
| SMTX-09 | Phase 7 | Pending | |
@@ -96,9 +96,9 @@ Which phases cover which requirements. Updated during roadmap creation.
9696
| DEDUP-03 | Phase 2 | Complete | isHex() deleted, only used internally by deleted hexFrom() (02-01) |
9797
| DEDUP-04 | Phase 2 | Complete | hexFrom() call sites use entity.toHex() or ccc.hexFrom(), local deleted (02-01) |
9898
| DEDUP-05 | Phase 2 | Complete | All 8 iCKB-unique utilities preserved unchanged (02-01) |
99-
| UDT-01 | Phase 3 | Pending | |
100-
| UDT-02 | Phase 3 | Pending | |
101-
| UDT-03 | Phase 3 | Pending | |
99+
| UDT-01 | Phase 3 | Complete | |
100+
| UDT-02 | Phase 3 | Complete | |
101+
| UDT-03 | Phase 3 | Complete | |
102102
| UDT-04 | Phase 5 | Pending | |
103103
| UDT-05 | Phase 5 | Pending | |
104104

@@ -109,4 +109,4 @@ Which phases cover which requirements. Updated during roadmap creation.
109109

110110
---
111111
*Requirements defined: 2026-02-21*
112-
*Last updated: 2026-02-23 after 02-01 execution (DEDUP-01 through DEDUP-05 completed; Phase 2 complete)*
112+
*Last updated: 2026-02-24 after Phase 3 completion (UDT-01 through UDT-03 completed; Phase 3 complete)*

.planning/ROADMAP.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Decimal phases appear between their surrounding integers in numeric order.
1414

1515
- [x] **Phase 1: SmartTransaction Removal (feature-slice)** - Delete SmartTransaction class and infrastructure across all packages; contribute 64-output DAO limit check to CCC core; migrate all method signatures to ccc.TransactionLike
1616
- [x] **Phase 2: CCC Utility Adoption** - Replace local utility functions that duplicate CCC equivalents across all packages; preserve iCKB-unique utilities
17-
- [ ] **Phase 3: CCC Udt Integration Investigation** - Assess feasibility of subclassing CCC's Udt class for iCKB's multi-representation value; design header access pattern; document decision
17+
- [x] **Phase 3: CCC Udt Integration Investigation** - Assess feasibility of subclassing CCC's Udt class for iCKB's multi-representation value; design header access pattern; document decision
1818
- [ ] **Phase 4: Deprecated CCC API Replacement** - Replace deprecated CCC API calls (`udtBalanceFrom`, etc.) with `@ckb-ccc/udt` equivalents in dao and order packages; finalize UDT handler replacement pattern based on Phase 3 findings
1919
- [ ] **Phase 5: @ickb/core UDT Refactor** - Implement IckbUdt class or refactor IckbUdtManager based on Phase 3 findings; preserve iCKB conservation law; replace deprecated CCC API calls in core
2020
- [ ] **Phase 6: SDK Completion Pipeline** - Wire IckbSdk facade to CCC-native fee completion; verify estimate() and maturity() work end-to-end
@@ -30,7 +30,7 @@ Decimal phases appear between their surrounding integers in numeric order.
3030
1. `SmartTransaction` class and `CapacityManager` class no longer exist in `@ickb/utils` source or exports
3131
2. `UdtHandler` interface and `UdtManager` class remain in `@ickb/utils` with method signatures updated from `SmartTransaction` to `ccc.TransactionLike` (full replacement deferred to Phase 3+)
3232
3. `getHeader()` function and `HeaderKey` type are removed from `@ickb/utils`; all call sites across dao/core/sdk inline CCC client calls (`client.getTransactionWithHeader()`, `client.getHeaderByNumber()`); `SmartTransaction.addHeaders()` call sites in DaoManager/LogicManager push to `tx.headerDeps` directly
33-
4. A 64-output NervosDAO limit check exists in CCC core (via `ccc-dev/`): `completeFee()` safety net, standalone async utility, and `ErrorNervosDaoOutputLimit` error class; all 6+ scattered checks across dao/core packages are replaced with calls to this CCC utility
33+
4. A 64-output NervosDAO limit check exists in CCC core (via `ccc-fork/`): `completeFee()` safety net, standalone async utility, and `ErrorNervosDaoOutputLimit` error class; all 6+ scattered checks across dao/core packages are replaced with calls to this CCC utility
3434
5. ALL manager method signatures across ALL 5 library packages accept `ccc.TransactionLike` instead of `SmartTransaction`, following CCC's convention (TransactionLike input, Transaction output with `Transaction.from()` conversion at entry point)
3535
6. `pnpm check:full` passes after each feature-slice removal step — no intermediate broken states
3636
**Plans**: 3 plans
@@ -60,14 +60,14 @@ Plans:
6060
**Depends on**: Nothing (can proceed in parallel with Phases 1-2; design investigation, not code changes)
6161
**Requirements**: UDT-01, UDT-02, UDT-03
6262
**Success Criteria** (what must be TRUE):
63-
1. A written feasibility assessment exists answering: can `IckbUdt extends udt.Udt` override `getInputsInfo()`/`getOutputsInfo()` to account for receipt cells and deposit cells alongside xUDT cells, without breaking CCC's internal method chains
64-
2. The header access pattern for receipt value calculation is designed and documented -- specifying whether `client.getCellWithHeader()`, `client.getHeaderByTxHash()`, or direct CCC client calls are used within the Udt override (note: `getHeader()` was removed in Phase 1)
63+
1. A written feasibility assessment exists answering: can `IckbUdt extends udt.Udt` override `infoFrom()` (or `getInputsInfo()`/`getOutputsInfo()`) to account for receipt cells and deposit cells alongside xUDT cells, without breaking CCC's internal method chains
64+
2. The header access pattern for receipt value calculation is designed and documented -- specifying whether `client.getCellWithHeader()`, `client.getTransactionWithHeader()`, or direct CCC client calls are used within the Udt override (note: `getHeader()` was removed in Phase 1)
6565
3. A decision document exists with one of three outcomes: (a) subclass CCC Udt, (b) keep custom interface, (c) hybrid approach -- with rationale for the chosen path
66-
**Plans**: TBD
66+
**Plans**: 2 plans
6767

6868
Plans:
69-
- [ ] 03-01: TBD
70-
- [ ] 03-02: TBD
69+
- [x] 03-01-PLAN.md — Trace CCC Udt internals end-to-end, verify infoFrom override feasibility, resolve open questions
70+
- [x] 03-02-PLAN.md — Write formal decision document (feasibility assessment, header access pattern, decision with rationale)
7171

7272
### Phase 4: Deprecated CCC API Replacement
7373
**Goal**: Deprecated CCC API calls are replaced with `@ckb-ccc/udt` equivalents in `@ickb/dao` and `@ickb/order`; UDT handler usage is finalized based on Phase 3 findings (method signatures and `addUdtHandlers()` removal already done in Phase 1)
@@ -89,7 +89,7 @@ Plans:
8989
**Requirements**: SMTX-05, SMTX-07, SMTX-10, UDT-04, UDT-05
9090
**Success Criteria** (what must be TRUE):
9191
1. The iCKB conservation law (`Input UDT + Input Receipts = Output UDT + Input Deposits`) is enforced correctly in the refactored code -- multi-representation UDT balance logic survives intact
92-
2. If Phase 3 concluded subclassing is viable: `IckbUdt extends udt.Udt` exists in `@ickb/core` with overridden `getInputsInfo()`/`getOutputsInfo()` that account for xUDT cells, receipt cells, and deposit cells
92+
2. If Phase 3 concluded subclassing is viable: `IckbUdt extends udt.Udt` exists in `@ickb/core` with overridden `infoFrom()` that accounts for xUDT cells, receipt cells, and deposit cells
9393
3. If Phase 3 concluded subclassing is not viable: `IckbUdtManager` is refactored to work with plain `ccc.Transaction` while maintaining a compatible interface for balance calculation
9494
4. `UdtHandler` interface and `UdtManager` class are removed from `@ickb/utils` (their responsibilities absorbed by the Phase 3 outcome implementation)
9595
5. No calls to deprecated CCC APIs exist in `@ickb/core`
@@ -139,7 +139,7 @@ Phases execute in numeric order: 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7
139139
|-------|----------------|--------|-----------|
140140
| 1. SmartTransaction Removal (feature-slice) | 3/3 | Complete | 2026-02-22 |
141141
| 2. CCC Utility Adoption | 1/1 | Complete | 2026-02-23 |
142-
| 3. CCC Udt Integration Investigation | 0/2 | Not started | - |
142+
| 3. CCC Udt Integration Investigation | 2/2 | Complete | 2026-02-24 |
143143
| 4. Deprecated CCC API Replacement | 0/2 | Not started | - |
144144
| 5. @ickb/core UDT Refactor | 0/3 | Not started | - |
145145
| 6. SDK Completion Pipeline | 0/2 | Not started | - |

.planning/STATE.md

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,34 @@
55
See: .planning/PROJECT.md (updated 2026-02-20)
66

77
**Core value:** Clean, CCC-aligned library packages published to npm that frontends can depend on to interact with iCKB contracts -- no Lumos, no abandoned abstractions, no duplicated functionality with CCC.
8-
**Current focus:** Phase 2: CCC Utility Adoption
8+
**Current focus:** Phase 4: Deprecated CCC API Replacement
99

1010
## Current Position
1111

12-
Phase: 2 of 7 (CCC Utility Adoption)
13-
Plan: 1 of 1 in current phase (phase complete)
14-
Status: Phase 02 complete, ready for phase 03
15-
Last activity: 2026-02-23 -- Plan 02-01 executed (local utility functions replaced with CCC equivalents)
12+
Phase: 3 of 7 (CCC Udt Integration Investigation) -- COMPLETE
13+
Plan: 2 of 2 in current phase (all plans complete)
14+
Status: Phase 3 complete, ready for Phase 4
15+
Last activity: 2026-02-24 -- Plan 03-02 decision document complete (execute-phase)
1616

17-
Progress: [███░░░░░░] 25%
17+
Progress: [███░░░░░░] 43%
1818

1919
## Performance Metrics
2020

2121
**Velocity:**
22-
- Total plans completed: 4
23-
- Average duration: ~15min
24-
- Total execution time: 1.0 hours
22+
- Total plans completed: 6
23+
- Average duration: ~12min
24+
- Total execution time: 1.2 hours
2525

2626
**By Phase:**
2727

2828
| Phase | Plans | Total | Avg/Plan |
2929
|-------|-------|-------|----------|
3030
| 01 | 3/3 | 52min | 17min |
3131
| 02 | 1/1 | 7min | 7min |
32+
| 03 | 2/2 | 9min | 4.5min |
3233

3334
**Recent Trend:**
34-
- Last 5 plans: 01-01 (~30min), 01-02 (~6min), 01-03 (~16min), 02-01 (~7min)
35+
- Last 5 plans: 01-03 (~16min), 02-01 (~7min), 03-01 (~5min), 03-02 (~4min)
3536
- Trend: accelerating
3637

3738
*Updated after each plan completion*
@@ -46,13 +47,13 @@ Recent decisions affecting current work:
4647
- [Roadmap]: Phase 1 uses feature-slice approach -- each removal chased across all packages, build stays green after every step. SMTX-01 (all signatures to TransactionLike) completed in Phase 1, not Phase 5.
4748
- [Roadmap]: UDT investigation (Phase 3) is a design phase that produces a decision document; its outcome determines UdtHandler/UdtManager replacement pattern used in Phases 4-5
4849
- [Roadmap]: Phases 4-5 reduced in scope: Phase 4 focuses on deprecated API replacement + UDT pattern finalization in dao/order; Phase 5 focuses on IckbUdt implementation + conservation law in core
49-
- [Phase 1 Context]: DAO 64-output limit check contributed to CCC core via ccc-dev/, CCC PR submitted during Phase 1
50+
- [Phase 1 Context]: DAO 64-output limit check contributed to CCC core via ccc-fork/, CCC PR submitted during Phase 1
5051
- [Phase 1 Context]: getHeader()/HeaderKey removed entirely -- inline CCC client calls at read-only call sites; addHeaders() call sites in DaoManager/LogicManager push to tx.headerDeps directly
5152
- [Phase 1 Context]: Script comparison must always use full Script.eq(), never just codeHash comparison
52-
- [01-01]: Added ccc-dev local patch mechanism (pins/local/*.patch) for deterministic replay of CCC modifications
53+
- [01-01]: Added ccc-fork local patch mechanism for deterministic replay of CCC modifications (now multi-file format: manifest + res-N.resolution + local-*.patch)
5354
- [01-01]: DaoManager.requestWithdrawal/withdraw client parameter placed before optional options for cleaner API
5455
- [01-01]: assertDaoOutputLimit uses early return when outputs <= 64 for zero-cost common case
55-
- [01-02]: Moved getHeader/HeaderKey to transaction.ts as non-exported internals (SmartTransaction still uses internally until Plan 03 deletion)
56+
- [01-02]: Moved getHeader/HeaderKey to transaction.ts as non-exported internals (deleted alongside SmartTransaction in 01-03)
5657
- [01-02]: TransactionHeader moved to utils.ts as canonical location for downstream consumers
5758
- [01-02]: Inlined CCC client calls use explicit null checks with descriptive error messages
5859
- [01-03]: All manager methods accept ccc.TransactionLike and return ccc.Transaction (TransactionLike pattern)
@@ -61,6 +62,14 @@ Recent decisions affecting current work:
6162
- [01-03]: SDK getCkb() uses direct client.findCellsOnChain instead of CapacityManager
6263
- [02-01]: Used Math.max() over Number(ccc.numMax()) for number-typed contexts to avoid unnecessary number→bigint→number round-trips
6364
- [02-01]: Used entity.toHex() for Entity args, ccc.hexFrom() for BytesLike args -- matching CCC's type-safe separation
65+
- [03-01]: infoFrom is the sole override point for IckbUdt -- no need to override getInputsInfo/getOutputsInfo
66+
- [03-01]: No upstream CCC changes required for IckbUdt subclass -- all override points are public with appropriate signatures
67+
- [03-01]: Caller responsibility for receipt/deposit cell discovery (not IckbUdt's filter) -- LogicManager/OwnedOwnerManager handle this
68+
- [03-01]: Accurate balance reporting only -- conservation law enforcement is separate from infoFrom
69+
- [03-02]: Decision: subclass CCC Udt (option a) -- IckbUdt extends udt.Udt with infoFrom override
70+
- [03-02]: Conservation law: accurate balance reporting only; on-chain script is authoritative enforcer; build-time validation optional later
71+
- [03-02]: Cell discovery boundary: infoFrom values cells already in transaction; callers (LogicManager/OwnedOwnerManager) find and add receipt/deposit cells
72+
- [03-02]: UdtHandler interface and UdtManager class to be deleted in Phase 5, replaced by udt.Udt type
6473

6574
### Pending Todos
6675

@@ -69,10 +78,13 @@ None yet.
6978
### Blockers/Concerns
7079

7180
- Resolved: CCC's `Transaction.getInputsCapacity()` handles DAO profit natively via `getInputsCapacityExtra()` -> `CellInput.getExtraCapacity()` -> `Cell.getDaoProfit()` (verified in STACK.md from CCC source). No standalone utility needed.
72-
- Research gap: CCC Udt `getInputsInfo()` signature needs verification for header fetching context -- must confirm during Phase 3 investigation.
81+
- Resolved: CCC Udt `getInputsInfo()` resolves inputs to `Cell` objects (which have `outPoint`) before passing to `infoFrom()`. `infoFrom()`'s `CellAnyLike` parameter has `outPoint?: OutPointLike | null` — optional, not absent. Input cells have outPoint (for header fetches), output cells don't. Both `infoFrom` and `getInputsInfo/getOutputsInfo` are viable override points for IckbUdt (verified during Phase 3 discuss-phase).
82+
- Resolved: STACK.md research correction applied — `client.getHeaderByTxHash()` (non-existent) replaced with `client.getTransactionWithHeader()` in STACK.md, ROADMAP.md Phase 3 success criterion #2, and REQUIREMENTS.md UDT-02.
83+
- Resolved: PR #328 stance updated during Phase 3 context — user decision is to design around PR #328 as target architecture (overrides research recommendation to "not wait for #328"). PR #328 is now integrated into `ccc-fork/ccc` via pins; FeePayer classes available at `ccc-fork/ccc/packages/core/src/signer/feePayer/`. The separate `reference/ccc-fee-payer` clone is no longer needed.
84+
- Resolved: `CellAny` has `capacityFree` getter (CCC transaction.ts:404-405) — 03-RESEARCH.md corrected (previously claimed `CellAny` lacked it).
7385

7486
## Session Continuity
7587

76-
Last session: 2026-02-23
77-
Stopped at: Completed 02-01-PLAN.md (Phase 02 complete)
78-
Resume file: .planning/phases/02-ccc-utility-adoption/02-01-SUMMARY.md
88+
Last session: 2026-02-24
89+
Stopped at: Completed 03-02-PLAN.md (Phase 3 complete)
90+
Resume file: Phase 4 planning needed

0 commit comments

Comments
 (0)