[LWDM] refactor(wallet-api): split monolithic react.ts and logic.ts into granular modules#15563
Closed
[LWDM] refactor(wallet-api): split monolithic react.ts and logic.ts into granular modules#15563
Conversation
Contributor
Web Tools Build Status
|
…nular modules Replace the monolithic `react.ts` (~1600 lines) and `logic.ts` (~530 lines) with a `react/` and `logic/` folder structure, each containing one file per handler or hook. Split `logic.test.ts` into isolated per-module test files under `logic/__tests__/`. **logic/ split:** - 9 modules: context, receiveOnAccount, signTransaction, signRawTransaction, broadcastTransaction, signMessage, bitcoin, exchange, storage - 9 test files + shared testHelpers.ts - No barrel file — all imports point to concrete paths **react/ split:** - 13 handler factory files in `react/handlers/` (currencyList, accountList, accountRequest, accountReceive, messageSign, storage, bitcoinSignPsbt, transactionSign, transactionSignRaw, transactionSignAndBroadcast, device, bitcoin, exchange) - 10 per-hook files (useWalletAPIServer, useConfig, usePermission, useCategories, useRecentlyUsed, useLocalLiveApp, useCacheBustedLiveApps, useDisclaimerRaw, useDAppManifestCurrencyIds, useSetWalletAPIAccounts) - Shared types.ts and safeGetRefValue.ts - No barrel file — all 37 consumer files updated to direct imports **Ref-based handler registration:** - Single `handlerDepsRef` holds all volatile data (walletState, manifest, accounts, tracking, config, UI callbacks, device transport) - All 22 handlers registered once in a single `useEffect([server])` via factory functions that read deps at call time through `getDeps()` - Eliminates ~20 useEffect blocks, prevents stale closures, and makes onLoad/onReload/onLoadError callbacks fully stable (empty deps)
83a0a5e to
75b5d36
Compare
|
Contributor
|
There as been no activity on this PR for the last 14 days. Please consider closing this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




✅ Checklist
npx changesetwas attached. I'll add one when opening for review📝 Description
Replace the monolithic
react.ts(~1600 lines) andlogic.ts(~530 lines) with areact/andlogic/folder structure, each containing one file per handler or hook. Splitlogic.test.tsinto isolated per-module test files underlogic/__tests__/.logic/ split:
react/ split:
react/handlers/(currencyList, accountList, accountRequest, accountReceive, messageSign, storage, bitcoinSignPsbt, transactionSign, transactionSignRaw, transactionSignAndBroadcast, device, bitcoin, exchange)Ref-based handler registration:
handlerDepsRefholds all volatile data (walletState, manifest, accounts, tracking, config, UI callbacks, device transport)useEffect([server])via factory functions that read deps at call time throughgetDeps()❓ Context
🧐 Checklist for the PR Reviewers