Skip to content

refactor: migrate API client to joinmarket-ng-api-ts #1305

Open
kishore08-07 wants to merge 9 commits into
develfrom
kishore/use-ng-api-ts
Open

refactor: migrate API client to joinmarket-ng-api-ts #1305
kishore08-07 wants to merge 9 commits into
develfrom
kishore/use-ng-api-ts

Conversation

@kishore08-07

@kishore08-07 kishore08-07 commented Jul 2, 2026

Copy link
Copy Markdown
Member

Summary

This PR implements the migration from the legacy @joinmarket-webui/joinmarket-api-ts API client package to @joinmarket-webui/joinmarket-ng-api-ts.

Key Changes

  • Global Error Type refactoring (replacing ErrorMessage with unknown / FastAPI-style errors).

  • SweepPage adaptations around Tumbler API endpoints:

    • Adapted SweepPage to utilize the new Tumbler API endpoints: tumblerplan, tumblerstart, tumblerstatus, and tumblerstop (replacing the old getschedule / runschedule / stopcoinjoinoptions endpoints).
    • Implemented a data-shape bridge in SweepPage.tsx (toSchedule mapper) that maps the new TumblerPlanResponse phases into the existing 7-tuple ScheduleEntry formats.
    • Rewrote mock queries and mutations in SweepPage.test.tsx to match the new Tumbler API methods.
  • Test updates to mock the new endpoints and packages.

- Uninstall legacy  (v0.3.0).
- Install new  (v1.0.0).
- Update package.json  for  to apply to the new ng-api package.

Signed-off-by: kishore08-07 <kishorebsm8@gmail.com>
@kishore08-07 kishore08-07 self-assigned this Jul 2, 2026
@kishore08-07 kishore08-07 added dependencies Pull requests that update a dependency file WIP Work in Progress SoB Issues, PRs, tasks, and discussions related to Summer of Bitcoin. labels Jul 2, 2026
Signed-off-by: kishore08-07 <kishorebsm8@gmail.com>
…bility

- Remove ErrorMessage type imports from @joinmarket-webui/joinmarket-ng-api-ts/jm across the codebase.
- Update error types in React Query hooks (useQuery, useMutation) and context states to use unknown instead of ErrorMessage.
- Update error handler callbacks (onError) to accept unknown type, adapting to the error type changes in the generated ng-api client.

Signed-off-by: kishore08-07 <kishorebsm8@gmail.com>
- Add nullish/undefined checks for sessionInfo.wallet_name in create, import, and login flows.
- Handle nullable progress field in rescanInfo by checking != null and defaulting to undefined.
- Fallback block_height to undefined if nullish in layout and session contexts.
- Default walletInfo.accounts to an empty array to prevent mapping errors if nullish.

Signed-off-by: kishore08-07 <kishorebsm8@gmail.com>
Signed-off-by: kishore08-07 <kishorebsm8@gmail.com>
Signed-off-by: kishore08-07 <kishorebsm8@gmail.com>
Signed-off-by: kishore08-07 <kishorebsm8@gmail.com>
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 88.12% (🎯 80%) 4290 / 4868
🔵 Statements 88.04% (🎯 80%) 4846 / 5504
🔵 Functions 86.19% (🎯 80%) 1523 / 1767
🔵 Branches 80.12% (🎯 80%) 2753 / 3436
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/App.tsx 66.01% 69.56% 60.97% 69.11% 59, 60, 61, 106, 125, 134, 139, 148-150, 258, 274-279, 293-324, 366-370, 434-441, 448, 459-466, 482, 497-504
src/components/MainWalletPage.tsx 87.5% 75% 81.81% 91.3% 52-53
src/components/create/CreateStepWalletDetails.tsx 100% 100% 100% 100%
src/components/create/CreateWalletPage.tsx 78.33% 57.14% 81.81% 77.58% 114-136, 164, 171, 183-185, 213-217, 230, 252
src/components/earn/EarnPage.tsx 91.66% 91.39% 88% 91.25% 211-214, 335, 398-408
src/components/earn/MoveToJarDialog.tsx 81.25% 92.72% 65.21% 82.66% 73, 101-102, 109-110, 117-118, 138, 190-194, 374-387, 402, 418
src/components/earn/OfferCard.tsx 100% 80% 100% 100%
src/components/earn/RenewBondDialog.tsx 82.52% 82.02% 65.51% 84.04% 75, 95, 121-122, 129-130, 137-138, 158, 210-214, 426-462, 477, 493
src/components/earn/CreateFidelityBondDialog/useCreateFidelityBondWizard.ts 89.81% 91.57% 92.15% 88.35% 177-178, 185-186, 193-194, 295-300, 328-332, 341-352, 357-366
src/components/earn/report/hooks/useQueryYieldgenReport.ts 100% 91.66% 100% 100%
src/components/import/ImportStepImportDetails.tsx 100% 100% 100% 100%
src/components/import/ImportStepWalletDetails.tsx 100% 100% 100% 100%
src/components/import/ImportWalletPage.tsx 79.74% 60% 75% 79.22% 88-89, 184, 256-257, 265-280, 298-329
src/components/layout/AppNavbar.tsx 81.08% 84.61% 30% 74.07% 135, 142, 191-254
src/components/layout/Layout.tsx 97.29% 76.47% 92.3% 96.96% 98
src/components/login/LoginCard.tsx 55.17% 87.8% 25% 48% 31, 37-38, 60-65, 85-153
src/components/login/LoginPage.tsx 87.5% 76.47% 87.5% 86.66% 75, 89-90, 100
src/components/receive/ReceivePage.tsx 84.21% 87.5% 78.57% 86.11% 41, 85-87, 107, 223-224
src/components/send/SendForm.tsx 92.17% 80.58% 93.33% 92.45% 83, 256, 326-327, 329, 422-423, 563-578
src/components/send/SendPage.tsx 90.71% 87.36% 87.5% 92.91% 120, 126, 184-187, 208, 214, 232, 484-485
src/components/send/collaborativeSend.ts 100% 100% 100% 100%
src/components/settings/AccountXpubsDialog.tsx 71.87% 60.78% 63.63% 67.1% 63-96, 129-151, 258, 267-268, 292-296, 308-309, 70
src/components/settings/RescanChainPage.tsx 93.33% 90% 100% 93.33% 146-147
src/components/settings/SeedPhraseDialog.tsx 94.28% 96.55% 81.81% 93.93% 79, 93
src/components/settings/fees/FeeConfigDialog.tsx 100% 100% 100% 100%
src/components/sweep/SweepPage.tsx 96.74% 89.91% 100% 96.46% 274, 280, 312, 332
src/components/wallet/WalletJarsDetailsContent.tsx 88.18% 73.68% 91.22% 86.53% 145-147, 157-160, 170-172, 182-185, 241, 262, 300-301, 318, 323-324, 333
src/context/JamSessionInfoContextProvider.tsx 100% 80.95% 100% 100%
src/context/JamWalletInfoContext.ts 73.07% 75% 50% 69.56% 107, 113-114, 123-124, 128-129
src/context/JamWalletInfoContextProvider.tsx 91.66% 77.61% 92.1% 91.5% 213, 230, 293, 301-303, 306-309
src/hooks/useJmConfig.ts 100% 50% 100% 100%
src/hooks/useQueryDisplayWallet.ts 100% 80% 100% 100%
src/hooks/useQueryJmInfo.ts 100% 100% 100% 100%
src/hooks/useQueryUtxos.ts 100% 87.5% 100% 100%
src/hooks/useRefreshSession.ts 94.73% 71.42% 100% 100% 58
src/hooks/useUtxoSelectionDialog.ts 86.9% 71.11% 96% 86.76% 103, 122-125, 145, 154, 160-164, 178-179
src/lib/config.ts 100% 100% 100% 100%
src/store/authStore.ts 100% 100% 100% 100%
src/store/jmSessionStore.ts 100% 100% 100% 100%
src/store/jmTxStore.ts 100% 100% 100% 100%
Generated in workflow #3305 for commit c9710ef by the Vitest Coverage Report Action

Comment thread src/components/import/ImportStepImportDetails.tsx Outdated
Comment thread src/components/import/ImportStepWalletDetails.tsx Outdated
Comment thread src/components/layout/AppNavbar.tsx Outdated
Comment thread package.json Outdated
Signed-off-by: kishore08-07 <kishorebsm8@gmail.com>
@kishore08-07 kishore08-07 marked this pull request as ready for review July 3, 2026 14:09
Copilot AI review requested due to automatic review settings July 3, 2026 14:09
@kishore08-07 kishore08-07 changed the title migrate to joinmarket-ng-api-ts refactor: migrate API client to joinmarket-ng-api-ts Jul 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the frontend from @joinmarket-webui/joinmarket-api-ts to @joinmarket-webui/joinmarket-ng-api-ts, updating API imports/mocks across the app and adapting a few flows (notably Sweep scheduler) to the new NG endpoints and types.

Changes:

  • Replace old JoinMarket API TS client/react-query helpers with joinmarket-ng-api-ts throughout application code and tests.
  • Update Sweep scheduler flow to use tumbler plan/start/status/stop APIs and convert tumbler status into the existing Schedule shape for UI.
  • Normalize error handling/type expectations in several components/hooks (moving away from the removed ErrorMessage type and using getErrorReason in UI).

Reviewed changes

Copilot reviewed 70 out of 71 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/stories/stories.test.ts Update API package mocks to NG package paths.
src/store/jmTxStore.ts Update API type import to NG package.
src/store/jmSessionStore.ts Update API type import to NG package.
src/store/jmSessionStore.test.ts Update API type import to NG package.
src/store/authStore.ts Update API type import to NG package.
src/lib/config.ts Switch client/types imports to NG package.
src/lib/config.test.ts Update createClient mock import path to NG package.
src/hooks/useUtxoSelectionDialog.ts Update react-query helper import to NG package.
src/hooks/useUtxoSelectionDialog.test.ts Update react-query helper mock to NG package.
src/hooks/useRefreshSession.ts Update session options/type imports to NG package.
src/hooks/useRefreshSession.test.ts Update session/react-query helper mocks to NG package.
src/hooks/useQueryUtxos.ts Update listutxos options + adjust local UTXO typing/error type.
src/hooks/useQueryUtxos.test.ts Update listutxos options mock import path to NG package.
src/hooks/useQueryJmInfo.ts Update version options/type imports to NG package.
src/hooks/useQueryJmInfo.test.ts Update version options mock import path to NG package.
src/hooks/useQueryDisplayWallet.ts Update displaywallet options/type imports to NG package.
src/hooks/useJmConfig.ts Update config mutation helper import to NG package.
src/hooks/useJmConfig.test.ts Update config mutation helper mock to NG package.
src/context/JamWalletInfoContextProvider.tsx Tolerate missing accounts + adapt branch parsing without non-null assertion.
src/context/JamWalletInfoContext.ts Update wallet display types and relax error typing to unknown.
src/context/JamSessionInfoContextProvider.tsx Update rescan options import + tweak progress/blockHeight handling.
src/context/JamSessionInfoContextProvider.test.tsx Update rescan options mock/type import to NG package.
src/components/wallet/WalletJarsDetailsContent.tsx Update freeze mutation helper import to NG package.
src/components/wallet/WalletJarsDetailsContent.test.tsx Update react-query helper mock + adjust meta typings in test fixtures.
src/components/sweep/SweepPage.tsx Replace schedule APIs with tumbler plan/start/status/stop and convert plan → schedule.
src/components/sweep/SweepPage.test.tsx Update sweep tests to mock tumbler APIs and plan/status behavior.
src/components/settings/SeedPhraseDialog.tsx Update seed options import + use getErrorReason for error display.
src/components/settings/SeedPhraseDialog.test.tsx Update seed options mock import path to NG package.
src/components/settings/RescanChainPage.tsx Update rescan API import to NG package.
src/components/settings/RescanChainPage.test.tsx Update rescan API mock import path to NG package.
src/components/settings/fees/FeeConfigDialog.tsx Update config mutation helper import to NG package.
src/components/settings/fees/FeeConfigDialog.test.tsx Update config mutation helper mock to NG package.
src/components/settings/AccountXpubsDialog.tsx Update seed options import + use getErrorReason for error display.
src/components/settings/AccountXpubsDialog.test.tsx Update seed options mock import path to NG package.
src/components/send/SendPage.tsx Update send mutations/types import to NG package; relax mutation error generics.
src/components/send/SendPage.test.tsx Update send react-query helper mocks to NG package.
src/components/send/SendForm.tsx Update getaddress import + relax callback error type to unknown.
src/components/send/SendForm.test.tsx Update getaddress mock import path to NG package.
src/components/send/collaborativeSend.ts Update request type imports to NG package.
src/components/receive/ReceivePage.tsx Update getaddress imports to NG package; relax onError typing.
src/components/receive/ReceivePage.test.tsx Update getaddress and query-key helper mocks to NG package.
src/components/MainWalletPage.tsx Use getErrorReason for wallet load error message formatting.
src/components/login/LoginPage.tsx Update wallet list/unlock helpers to NG package; tighten active-wallet detection.
src/components/login/LoginPage.test.tsx Update login react-query helper mocks to NG package.
src/components/login/LoginCard.tsx Relax list-wallet error type to unknown and render via getErrorReason.
src/components/layout/Layout.tsx Normalize optional blockHeight to undefined when absent.
src/components/layout/AppNavbar.tsx Update session type import; handle rescan progress via isValidNumber.
src/components/import/ImportWalletPage.tsx Update wallet import flows to NG package APIs/helpers.
src/components/import/ImportWalletPage.test.tsx Update import flow mocks to NG package.
src/components/import/ImportStepWalletDetails.tsx Treat session active only when wallet name is present.
src/components/import/ImportStepImportDetails.tsx Treat session active only when wallet name is present.
src/components/earn/report/hooks/useQueryYieldgenReport.ts Update yieldgen imports to NG package and adjust response parsing.
src/components/earn/report/hooks/useQueryYieldgenReport.test.ts Update mocks to NG package.
src/components/earn/RenewBondDialog.tsx Update earn mutations/types imports; relax onError typing.
src/components/earn/RenewBondDialog.test.tsx Update earn react-query helper mocks to NG package.
src/components/earn/OfferCard.tsx Harden string coercion for offer fields under new typings.
src/components/earn/OfferCard.test.tsx Adjust test fixtures typing for new Offer shape.
src/components/earn/MoveToJarDialog.tsx Update earn mutations/types imports; relax onError typing.
src/components/earn/MoveToJarDialog.test.tsx Update earn react-query helper mocks to NG package.
src/components/earn/EarnPage.tsx Update maker start/stop helpers/types; relax onError typing.
src/components/earn/EarnPage.test.tsx Update earn page helper mocks to NG package.
src/components/earn/CreateFidelityBondDialog/useCreateFidelityBondWizard.ts Update fidelity bond helpers/types; relax onError typing.
src/components/earn/CreateFidelityBondDialog/useCreateFidelityBondWizard.test.ts Update helper mocks to NG package.
src/components/earn/CreateFidelityBondDialog/CreateFidelityBondDialogSteps.test.tsx Update test fixture to satisfy new tx result shape.
src/components/create/CreateWalletPage.tsx Update create wallet flow to NG package APIs/helpers.
src/components/create/CreateWalletPage.test.tsx Update create flow mocks to NG package.
src/components/create/CreateStepWalletDetails.tsx Only show “other wallet active” when a wallet name is present.
src/App.tsx Update lockwallet/token imports; use getErrorReason for token refresh errors.
src/App.test.tsx Update app-level API mocks to NG package.
package.json Replace dependency/override from joinmarket-api-ts to joinmarket-ng-api-ts.
package-lock.json Lockfile updates reflecting joinmarket-ng-api-ts@1.0.0 and dependency graph changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/context/JamSessionInfoContextProvider.tsx
Comment thread src/components/earn/report/hooks/useQueryYieldgenReport.ts
Signed-off-by: kishore08-07 <kishorebsm8@gmail.com>
@kishore08-07 kishore08-07 removed the WIP Work in Progress label Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file SoB Issues, PRs, tasks, and discussions related to Summer of Bitcoin.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants