Repository navigation
refactor(onekeylib): split the Protocol V2 client by responsibility - #1010
Conversation
Move only: the module becomes protocol_v2/client.py with parent-relative imports, and protocol_v2/__init__.py re-exports OneKeyClientV2, SessionV2 and REQUIRED_V2_MESSAGES, so `from onekeylib.protocol_v2 import ...` keeps working. Keeping the move apart from the split lets `git log --follow` trace the client's history. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No behavior change. OneKeyClientV2 keeps every public method and the order of every request it sends; its parts move into modules of their own: - link: message encoding over proto_link, the negotiated link state (LinkState) and the ProtocolInfo check. - requests: which requests are mid-workflow, seedless, interactive, and so on. - failures: failure replies to exceptions (failure_error). - sessions: SessionV2, the passphrase request each PassphraseSetting sends, and the checks on DeviceSession replies. - workflow: the signing exchange a session keeps reserved (WorkflowReservation), formerly three client attributes. The tests reach the reservation as client._workflow.session/.token instead of the old attributes; their assertions are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
|
@codex security review |
|
Cursor review failed. Remote error: |
|
Skipping Bugbot: Bugbot is disabled for this repository. Visit the Bugbot dashboard to update your settings. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Step 1 of the onekeylib architecture cleanup: split the 870-line
protocol_v2.pyby responsibility. No behavior change.OneKeyClientV2keeps every public method and sends the same requests in the same order.Stacked on #1003. The base is
feat/onekeylib-python. Once #1003 merges, retarget this PR toonekey.protocol_v2/client.pyOneKeyClientV2: request dispatch, device state, the session registry (655 lines, down from 870)protocol_v2/link.pyproto_link,LinkState(handshake, eventless, generation), theProtocolInfocheckprotocol_v2/requests.pyprotocol_v2/failures.pyfailure_error():V2Failure/Failurereplies to exceptionsprotocol_v2/sessions.pySessionV2,passphrase_request()(which passphrase request eachPassphraseSettingsends), checks onDeviceSessionrepliesprotocol_v2/workflow.pyWorkflowReservation: the signing exchange a session keeps reserved (formerly three client attributes)from onekeylib.protocol_v2 import OneKeyClientV2, SessionV2, REQUIRED_V2_MESSAGESstill works. The Electrum plugin imports nothing fromprotocol_v2directly.The first commit only moves the file, so
git log --followstill traces the client's history.Tests
pytest testspassed 69.flake8 --select=E9,F63,F7,F82,F401,F811passed. The only test change: two private attributes are now reached throughclient._workflow.session/.token. No assertion changed.tests/plugins/onekey, run against this source) passed 164.onekeylib/protocol_v2/*.pyand no staleprotocol_v2.py.Next steps (separate PRs)
btc.pystops probing V2 internals withgetattrand uses a base-class signing guard instead.get_client/get_default_sessionstop dispatching onisinstance.tools.__getattr__). Name the timeout and seed-domain constants.🤖 Generated with Claude Code