Skip to content

Refactor SDK transaction planning modules#61

Merged
phroi merged 8 commits into
masterfrom
review/sdk-split
Jul 8, 2026
Merged

Refactor SDK transaction planning modules#61
phroi merged 8 commits into
masterfrom
review/sdk-split

Conversation

@phroi

@phroi phroi commented Jul 8, 2026

Copy link
Copy Markdown
Member

Why

The SDK facade had grown into one large module that mixed L1 state scans, conversion planning, transaction completion, send-and-wait behavior, and withdrawal selection. Splitting those concerns makes the package easier to review and gives API Extractor a stable package boundary for the SDK surface.

Changes

  • Split SDK client, conversion, estimate, send, and withdrawal logic into focused packages/sdk/src modules.
  • Move SDK coverage into a package test tree with targeted suites for state projection, conversion planning, send/wait lifecycle, transaction completion, and withdrawal selection.
  • Keep the legacy bot withdrawal-selection policy local to apps/bot so the split SDK does not re-export bot-specific cleanup heuristics.
  • Update current app/test fixtures to model native iCKB as real UDT cell data, matching the split SDK projection path.

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

Copy link
Copy Markdown

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 modularizes the @ickb/sdk package by refactoring the monolithic sdk.ts file into a clean directory structure under src/client, src/conversion, src/estimate, src/send, and src/withdrawal. It also introduces a build configuration using api-extractor, updates package exports, and expands the test suite. Feedback is provided on sdk_error.ts to explicitly handle Date objects during JSON serialization to prevent potential runtime errors or silent data loss.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread packages/sdk/src/client/sdk_error.ts Outdated
@phroi

phroi commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

/gemini review

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

Copy link
Copy Markdown

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 refactors and modularizes the SDK package by splitting the monolithic sdk.ts into specialized modules for L1 state scanning, conversion planning, maturity estimation, and transaction sending, alongside introducing ring-based withdrawal selection helpers. The review feedback highlights security concerns regarding potential information disclosure in send_and_wait.ts, suggesting that raw polling errors be sanitized to safe classifiers before being attached to transaction confirmation errors or lifecycle events to prevent leaking sensitive node URLs or credentials.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread packages/sdk/src/send/send_and_wait.ts
Comment thread packages/sdk/src/send/send_and_wait.ts
@phroi

phroi commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

/gemini review

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

Copy link
Copy Markdown

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 refactors the monolithic sdk.ts file in the SDK package, splitting its functionality into modular components under client, conversion, estimate, send, and withdrawal directories. It also updates the package configuration, build scripts, and test suites to align with this new structure. The code review feedback highlights potential issues with error handling and deduplication: wrapping unexpected errors by attaching the raw error object as a cause could leak sensitive information, and using the unique helper on logical entities like ccc.Script may fail to deduplicate structurally identical instances if it relies on reference equality.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread packages/sdk/src/client/sdk_error.ts
Comment thread packages/sdk/src/constants.ts
Comment thread packages/sdk/src/client/sdk_l1_class.ts
@phroi

phroi commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

/gemini review

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

Copy link
Copy Markdown

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 refactors the iCKB SDK by modularizing its core architecture into smaller, specialized classes and subdirectories (such as client, conversion, estimate, send, and withdrawal). It replaces the previous ready withdrawal cleanup selection logic with a more robust ring-based withdrawal selection mechanism. Additionally, it updates the build and test configurations, including tsconfig, vitest, and package exports, and moves test files to a dedicated test directory. There are no review comments provided, so I have no feedback to offer on the review itself.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@phroi

phroi commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

/gemini review

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

Copy link
Copy Markdown

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 refactors the iCKB SDK by modularizing the monolithic sdk.ts file into distinct classes and subdirectories for conversion, estimation, sending, and withdrawal logic. It also introduces a ring-based withdrawal selection algorithm and updates the test suite. The review feedback focuses on improving robustness when accessing internal collections with previously validated indices or keys (specifically in firstCkbMaturityAtOrAbove, selectByMasks, ringSegments, and selectionKey) by throwing explicit errors instead of using optional chaining, non-null assertions, or silently returning undefined.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread packages/sdk/src/estimate/sdk_maturity.ts
Comment thread packages/sdk/src/withdrawal/withdrawal_best_fit_support.ts
Comment thread packages/sdk/src/withdrawal/withdrawal_ring_core.ts
Comment thread packages/sdk/src/withdrawal/withdrawal_selection.ts
@phroi

phroi commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

/gemini review

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

Copy link
Copy Markdown

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 refactors the SDK package by modularizing the monolithic sdk.ts file into smaller, specialized modules under src/client, src/conversion, src/estimate, src/send, and src/withdrawal. It introduces structured SDK classes (IckbSdkBase, IckbSdkConversion, IckbSdkL1, and IckbSdk), adds ring-based withdrawal selection helpers, and implements a best-fit algorithm for ready deposit selection. Additionally, the build configuration, package exports, and testing suite have been updated and expanded with comprehensive tests. As there are no review comments provided, I have no feedback to address.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@phroi

phroi commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

LGTM

Phroi %345

@phroi phroi merged commit ca51bf8 into master Jul 8, 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.

1 participant