Skip to content

refactor(wallet): managed-only context with wallet boot gate - #3567

Merged
baktun14 merged 9 commits into
mainfrom
refactor/wallet-managed-only-context-boot-gate
Aug 7, 2026
Merged

refactor(wallet): managed-only context with wallet boot gate#3567
baktun14 merged 9 commits into
mainfrom
refactor/wallet-managed-only-context-boot-gate

Conversation

@baktun14

@baktun14 baktun14 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Why

Console is managed-wallets-only (the server holds and signs the wallet), but the WalletProvider context still carried the custodial-era surface: a hardcoded isManaged: true feeding statically dead !isManaged branches across consumers, dead fields (isWalletLoaded was constant true, walletName/logout/isOnboarding had zero consumers, isWalletConnectedhasManagedWallet), and vestiges like the deposit-modal ACT/auto-mint path and useMintACT. On top of that, every consumer had to handle isWalletLoading/isWalletInitializing individually.

This PR finishes the managed-only refactor and moves the wallet-loading wait to a single boot gate: the app now waits (behind the existing shared boot overlay) until the wallet record is resolved from the backend, so below the provider the wallet state is always settled and consumers carry no wallet-loading logic at all.

Stacked on #3563 (refactor/wallet-remove-signed-in-with-trial-flag) — retarget/rebase to main once that merges.

What

Boot gate (WalletProvider)

  • The provider renders <BootLoading /> (shared overlay, same idiom as RequireAuth) instead of children until the initial wallet-existence lookup settles.
  • The gate keys on the initial lookup only — never on trial creation, which would blank the app mid-onboarding. Anonymous users never wait (lookup is keyed on the registered userId). The 5s address poll cannot re-engage the gate (a no-wallet response is a settled null success).

Slimmed context API (drop the now-redundant "managed" qualifier)

type ContextType = {
  address: string;
  hasWallet: boolean;        // merges isWalletConnected + hasManagedWallet (both were !!managedWallet)
  isWalletCreating: boolean; // trial provisioning in flight (cross-instance), for onboarding consumers
  createWallet: () => void;  // was connectManagedWallet
  signAndBroadcastTx: (msgs: EncodeObject[]) => Promise<boolean>;
  denom: string;
  isTrialing: boolean;
  creditAmount?: number;
  topUpMinAmountUsd: number;
  walletError?: AppError;    // was managedWalletError
};

Removed: isManaged, isWalletLoaded, isWalletLoading, isWalletInitializing, walletName, logout, isOnboarding, useIsManagedWalletUser. hasWallet ≠ has-address: sites needing a provisioned address keep the hasWallet && !!address conjunct as a local (RequireOnboarding, useOnboardingChrome, useIsOnboarded).

Dead custodial-era code deleted

  • Deposit modal ACT/auto-mint path, useMintACT, getMintACTMsg, "mintingACT" tx-modal state.
  • Dead !isManaged branches in ~12 consumers (GetStartedStepper, DeploymentListRow, ApiKeyList, useWalletBalance incl. TX_FEE_BUFFER, AccountStatsCards/AccountHeader custodial cards/props, CreateLease manifest snackbar, useManagedDeploymentConfirm, escrow alert, …).
  • No-op Guard(useIsManagedWalletUser) on /billing, /usage, /payment-methods (+ the now-unused Guard/composeGuards HOC), Layout's isUsingWallet wallet-loading branch, isWalletModalOpen atom, dead apiUtils builders (certificatesList, allowancesIssued, allowancesGranted, granterGrants), custodial analytics types, name/isManaged constants in the ManagedLocalWallet storage shape.
  • useManagedWallet stops decorating the wallet with username/isWalletConnected/isWalletLoaded/selected (nothing read them) and exposes isCreating (cross-instance via useIsMutating).

Behavioral notes

  • Registered users briefly see the boot overlay on first load of any page (public included) until v1/wallets resolves — one query, replacing the per-widget spinners/Loading wallet... states.
  • User-visible copy fix (own commit): the minimum-escrow alert rendered a literal $$ (fix(deployment)).
  • Analytics events emitted are unchanged; only never-emitted custodial variants were removed from types/mappings.
  • New WalletProvider.spec.tsx (13 cases) covers the gate (blocks registered users mid-lookup, anonymous pass-through, creation never blanks the app, transition mounts children) and the new context shape.

Verification

  • npm run test:unit: 3000 passed; the only failures are 3 pre-existing on the base branch (useScreenedProviders, provider-proxy.service, one useProviderJwt case) — verified failing on a clean checkout too.
  • npm run lint -- --quiet clean; npm run type-check has zero new errors vs the base branch (baseline has long-standing spec-typing errors; this PR fixes one of them).
  • Headless smoke against next dev with mocked /api/auth/me + held v1/wallets: boot overlay covers the app while the lookup is in flight, releases the moment it settles, app renders (script: dev-server + Playwright route interception).

Follow-ups (out of scope)

  • addWalletEssentials decorations in packages/http-sdk are now unused by deploy-web.
  • PaymentMethodsDisplay.test.tsx.spec.tsx rename (currently not picked up by vitest's *.spec include; typechecked only).
  • Product-copy pass on GetStartedStepper's crypto-flavored min-balance tooltip.

Summary by CodeRabbit

  • New Features
    • Simplified wallet availability and creation states across onboarding, deployment, billing, and account screens.
    • Added clearer wallet creation progress and error handling.
    • Account and deployment views now consistently display balances and funding actions.
    • Deposit amounts use dollar-denominated credits, with submissions disabled when balances are insufficient.
  • Bug Fixes
    • Deployment data loads without waiting for wallet loading to complete.
    • Wallet readiness and onboarding checks are more reliable.
  • Removed
    • Removed automatic ACT minting and related transaction flows.

@baktun14
baktun14 requested a review from a team as a code owner August 6, 2026 12:57
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2fdac855-def4-4f4b-ba3e-89b3966ba252

📥 Commits

Reviewing files that changed from the base of the PR and between 963b86c and 6cadcd9.

📒 Files selected for processing (6)
  • apps/deploy-web/src/components/deployments/DeploymentListRow.tsx
  • apps/deploy-web/src/components/get-started/GetStartedStepper.spec.tsx
  • apps/deploy-web/src/components/get-started/GetStartedStepper.tsx
  • apps/deploy-web/src/components/home/AccountStatsCards/AccountStatsCards.spec.tsx
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodsDisplay/PaymentMethodsDisplay.spec.tsx
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodsDisplay/PaymentMethodsDisplay.test.tsx
💤 Files with no reviewable changes (1)
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodsDisplay/PaymentMethodsDisplay.test.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/deploy-web/src/components/home/AccountStatsCards/AccountStatsCards.spec.tsx
  • apps/deploy-web/src/components/deployments/DeploymentListRow.tsx

📝 Walkthrough

Walkthrough

The deploy-web wallet model now uses hasWallet, wallet creation state, and wallet errors instead of managed-wallet lifecycle state. ACT minting and related transaction flows were removed. Funding, onboarding, deployment, account, layout, and wallet-dependent hooks were updated with matching tests.

Changes

Wallet model and application migration

Layer / File(s) Summary
Wallet provider and wallet lifecycle
apps/deploy-web/src/context/WalletProvider/*, apps/deploy-web/src/hooks/useManagedWallet.ts
The wallet context exposes wallet availability, creation, signing, and wallet errors. Initialization now gates rendering through BootLoading.
Onboarding and access flows
apps/deploy-web/src/components/onboarding/*, apps/deploy-web/src/hooks/useIsOnboarded.ts, apps/deploy-web/src/hooks/useOnboardingChrome.ts
Onboarding uses hasWallet, isWalletCreating, createWallet, and walletError for redirects, loading, completion, lease queries, and error handling.
Funding and deployment behavior
apps/deploy-web/src/components/deployments/*, apps/deploy-web/src/components/sdl/*, apps/deploy-web/src/hooks/useWalletBalance.ts
Deposit submission converts amounts directly. ACT deposits are disabled when the ACT balance is insufficient. Managed-wallet pricing, escrow, and minting branches were removed.
Account, layout, and deployment surfaces
apps/deploy-web/src/components/home/*, apps/deploy-web/src/components/layout/*, apps/deploy-web/src/components/new-deployment/*
Account cards, layout readiness, wallet status, deployment creation, and transaction state no longer use legacy wallet lifecycle fields.
Wallet integrations and removed APIs
apps/deploy-web/src/hooks/useProvider*, apps/deploy-web/src/services/analytics/*, apps/deploy-web/src/utils/*, apps/deploy-web/src/pages/*, apps/deploy-web/src/store/walletStore.ts
Credential and JWT checks use hasWallet. Custodial analytics, ACT minting utilities, obsolete API URL builders, and the managed-wallet guard export were removed.

Estimated code review effort: 5 (Critical) | ~120 minutes

Possibly related PRs

Suggested reviewers: ygrishajev, stalniy

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/wallet-managed-only-context-boot-gate

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/deploy-web/src/components/deployments/DeploymentListRow.tsx

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

apps/deploy-web/src/components/get-started/GetStartedStepper.spec.tsx

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

apps/deploy-web/src/components/get-started/GetStartedStepper.tsx

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

  • 2 others

Comment @coderabbitai help to get the list of available commands.

@baktun14
baktun14 force-pushed the refactor/wallet-managed-only-context-boot-gate branch from 77b2e3f to b33b72d Compare August 6, 2026 13:06

@claude claude 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.

This is a large, cross-cutting refactor (72 files) that changes core wallet-boot behavior — the app now blocks behind a boot overlay on every page until the wallet lookup settles, and the WalletProvider context API is reshaped for ~20 consumers. No bugs were found by the automated review, but the scope and behavioral change to app boot warrant a human look.

Extended reasoning...

Overview

The PR removes the custodial-era wallet surface (isManaged, isWalletLoaded, isWalletLoading, isWalletInitializing, walletName, logout, isOnboarding, useIsManagedWalletUser) from WalletProvider and replaces it with a slimmer hasWallet/isWalletCreating/createWallet API. It also moves wallet-loading logic out of roughly 20 individual consumers and into a single boot gate in WalletProvider that renders BootLoading instead of children until the initial wallet-existence lookup settles. Dead custodial code (ACT auto-mint path, useMintACT, unused apiUtils builders, the Guard/composeGuards HOC, etc.) is deleted, and one visible copy fix (literal double-dollar-sign in the escrow alert) is included.

Security risks

No injection, auth-bypass, or data-exposure concerns — this is UI/context wiring, not auth or crypto logic. The removed Guard HOC on /billing, /usage, /payment-methods was a no-op (useIsManagedWalletUser always resolved true for a managed-only app), so removing it doesn't change access control.

Level of scrutiny

This warrants a human pass despite finding no bugs: it changes the loading/boot sequence for the entire app (every registered user now waits on a new full-screen gate on every page load), and it touches a large number of call sites where subtle behavioral differences (dropped isManaged branches, merged isWalletConnected/hasManagedWallet into hasWallet) could regress edge cases not fully exercised by unit tests. This is large-scale design-decision territory rather than a mechanical rename.

Other factors

Test coverage looks substantial (a new WalletProvider.spec.tsx with 13 cases covering the gate, plus updated specs across nearly every touched consumer), and the PR description documents manual verification (unit tests, lint, type-check, and a headless boot-overlay smoke test). The PR itself notes it is stacked on #3563 and needs retargeting/rebasing to main, which is worth confirming before merge.

Base automatically changed from refactor/wallet-remove-signed-in-with-trial-flag to main August 7, 2026 10:21
@baktun14
baktun14 force-pushed the refactor/wallet-managed-only-context-boot-gate branch from b33b72d to 963b86c Compare August 7, 2026 10:29
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.92308% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.35%. Comparing base (6822a25) to head (6cadcd9).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...b/src/components/deployments/DeploymentListRow.tsx 0.00% 6 Missing ⚠️
.../DeploymentDepositModal/DeploymentDepositModal.tsx 82.60% 4 Missing ⚠️
...eb/src/components/deployments/DeploymentDetail.tsx 0.00% 2 Missing and 2 partials ⚠️
...-web/src/components/deployments/DeploymentList.tsx 0.00% 3 Missing and 1 partial ⚠️
...ploy-web/src/hooks/useManagedDeploymentConfirm.tsx 0.00% 3 Missing ⚠️
apps/deploy-web/src/hooks/useWalletBalance.ts 0.00% 2 Missing and 1 partial ⚠️
...s/deploy-web/src/components/home/HomeContainer.tsx 0.00% 1 Missing and 1 partial ⚠️
.../deploy-web/src/components/api-keys/ApiKeyList.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3567      +/-   ##
==========================================
- Coverage   75.90%   75.35%   -0.55%     
==========================================
  Files        1159     1067      -92     
  Lines       30270    27708    -2562     
  Branches     7529     6988     -541     
==========================================
- Hits        22976    20879    -2097     
+ Misses       6432     6020     -412     
+ Partials      862      809      -53     
Flag Coverage Δ *Carryforward flag
api 88.92% <ø> (ø) Carriedforward from 963b86c
deploy-web 66.14% <76.92%> (+0.31%) ⬆️
log-collector ?
notifications 93.84% <ø> (ø) Carriedforward from 963b86c
provider-console 81.38% <ø> (ø) Carriedforward from 963b86c
provider-inventory ?
provider-proxy 88.17% <ø> (ø) Carriedforward from 963b86c
tx-signer ?

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...nPane/HardwareSection/useTrialGate/useTrialGate.ts 100.00% <100.00%> (ø)
...b/src/components/get-started/GetStartedStepper.tsx 66.66% <100.00%> (-4.17%) ⬇️
...s/deploy-web/src/components/home/AccountHeader.tsx 33.33% <100.00%> (+8.33%) ⬆️
...nents/home/AccountStatsCards/AccountStatsCards.tsx 100.00% <100.00%> (ø)
...eb/src/components/home/YourAccount/YourAccount.tsx 94.33% <100.00%> (ø)
apps/deploy-web/src/components/layout/Layout.tsx 96.15% <100.00%> (+2.82%) ⬆️
...loy-web/src/components/layout/TransactionModal.tsx 50.00% <ø> (-25.00%) ⬇️
.../deploy-web/src/components/layout/WalletStatus.tsx 100.00% <100.00%> (ø)
...ponents/new-deployment/CreateLease/CreateLease.tsx 75.00% <100.00%> (ø)
...nents/new-deployment/ManifestEdit/ManifestEdit.tsx 53.20% <ø> (ø)
... and 30 more

... and 98 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/deploy-web/src/components/onboarding/steps/PaymentMethodsDisplay/PaymentMethodsDisplay.test.tsx (1)

314-321: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Convert this test to Vitest.

Replace jest.Mock and other Jest APIs with Mock, vi.fn, and vi APIs from vitest.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/deploy-web/src/components/onboarding/steps/PaymentMethodsDisplay/PaymentMethodsDisplay.test.tsx`
around lines 314 - 321, Convert the PaymentMethodsDisplay test setup and all
related test code from Jest to Vitest: replace jest.Mock types with Vitest’s
Mock type, jest.fn with vi.fn, and any other Jest APIs with their vi
equivalents, importing the required symbols from vitest while preserving
existing test behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/deploy-web/src/components/deployments/DeploymentListRow.tsx`:
- Around line 226-232: Update the spent amount conversion in the
DeploymentListRow rendering to call udenomToDenom with precision 6, matching the
escrowBalanceInDenom conversion used for Balance. Keep the existing amountSpent
fallback and PriceValue rendering unchanged.

In `@apps/deploy-web/src/components/get-started/GetStartedStepper.tsx`:
- Around line 132-134: Remove the legacy ACT readiness guidance around the
GetStartedStepper balance message, including the ACT-related condition and
acquire-ACT warning. Ensure readiness is derived only from the managed-wallet
funding balance (such as USDC), so a funded wallet without ACT is treated as
ready; otherwise remove the obsolete block entirely.

In
`@apps/deploy-web/src/components/home/AccountStatsCards/AccountStatsCards.spec.tsx`:
- Around line 19-23: Update the test case “renders deployment escrow USD” to
assert the complete formatted value “$42.00 used in deployments” in the rendered
output, ensuring totalDeploymentEscrowUSD is actually reflected rather than
checking only the static suffix.

In `@apps/deploy-web/src/hooks/useIsOnboarded.ts`:
- Around line 16-21: The useIsOnboarded hook currently converts an unresolved or
failed useLeaseExistenceQuery into false, potentially triggering premature
onboarding redirects. Update useIsOnboarded and its routing consumers to
preserve loading and error states, ensuring redirects wait for a settled query
and lease lookup errors follow useOnboardingChrome’s fail-open behavior.

In `@apps/deploy-web/src/utils/walletUtils.ts`:
- Line 52: Remove the duplicate ManagedWalletUpdate type alias declaration in
walletUtils.ts, keeping exactly one definition of the existing type so
TypeScript compilation succeeds.

---

Outside diff comments:
In
`@apps/deploy-web/src/components/onboarding/steps/PaymentMethodsDisplay/PaymentMethodsDisplay.test.tsx`:
- Around line 314-321: Convert the PaymentMethodsDisplay test setup and all
related test code from Jest to Vitest: replace jest.Mock types with Vitest’s
Mock type, jest.fn with vi.fn, and any other Jest APIs with their vi
equivalents, importing the required symbols from vitest while preserving
existing test behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3f665a90-c34a-42ab-9bf5-0e4c6cfd5078

📥 Commits

Reviewing files that changed from the base of the PR and between 6822a25 and 963b86c.

📒 Files selected for processing (72)
  • apps/deploy-web/src/components/api-keys/ApiKeyList.tsx
  • apps/deploy-web/src/components/deployments/ConfigureDeployment/ConfigurationPane/HardwareSection/useTrialGate/useTrialGate.spec.ts
  • apps/deploy-web/src/components/deployments/ConfigureDeployment/ConfigurationPane/HardwareSection/useTrialGate/useTrialGate.ts
  • apps/deploy-web/src/components/deployments/DeploymentDepositModal/DeploymentDepositModal.spec.tsx
  • apps/deploy-web/src/components/deployments/DeploymentDepositModal/DeploymentDepositModal.tsx
  • apps/deploy-web/src/components/deployments/DeploymentDetail.tsx
  • apps/deploy-web/src/components/deployments/DeploymentDetailTopBar/DeploymentDetailTopBar.spec.tsx
  • apps/deploy-web/src/components/deployments/DeploymentList.tsx
  • apps/deploy-web/src/components/deployments/DeploymentListRow.tsx
  • apps/deploy-web/src/components/deployments/ManifestUpdate/ManifestUpdate.spec.tsx
  • apps/deploy-web/src/components/get-started/GetStartedStepper.spec.tsx
  • apps/deploy-web/src/components/get-started/GetStartedStepper.tsx
  • apps/deploy-web/src/components/home/AccountHeader.tsx
  • apps/deploy-web/src/components/home/AccountStatsCards/AccountStatsCards.spec.tsx
  • apps/deploy-web/src/components/home/AccountStatsCards/AccountStatsCards.tsx
  • apps/deploy-web/src/components/home/HomeContainer.tsx
  • apps/deploy-web/src/components/home/YourAccount/YourAccount.spec.tsx
  • apps/deploy-web/src/components/home/YourAccount/YourAccount.tsx
  • apps/deploy-web/src/components/layout/Layout.spec.tsx
  • apps/deploy-web/src/components/layout/Layout.tsx
  • apps/deploy-web/src/components/layout/TransactionModal.tsx
  • apps/deploy-web/src/components/layout/WalletStatus.spec.tsx
  • apps/deploy-web/src/components/layout/WalletStatus.tsx
  • apps/deploy-web/src/components/new-deployment/CreateLease/CreateLease.spec.tsx
  • apps/deploy-web/src/components/new-deployment/CreateLease/CreateLease.tsx
  • apps/deploy-web/src/components/new-deployment/ManifestEdit/ManifestEdit.spec.tsx
  • apps/deploy-web/src/components/new-deployment/ManifestEdit/ManifestEdit.tsx
  • apps/deploy-web/src/components/new-deployment/NewDeploymentContainer/NewDeploymentContainer.tsx
  • apps/deploy-web/src/components/new-deployment/SdlBuilder.spec.tsx
  • apps/deploy-web/src/components/onboarding/OnboardingContainer/OnboardingContainer.spec.tsx
  • apps/deploy-web/src/components/onboarding/OnboardingContainer/OnboardingContainer.tsx
  • apps/deploy-web/src/components/onboarding/RequireOnboarding/RequireOnboarding.spec.tsx
  • apps/deploy-web/src/components/onboarding/RequireOnboarding/RequireOnboarding.tsx
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodContainer/PaymentMethodContainer.spec.tsx
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodContainer/PaymentMethodContainer.tsx
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodStep/PaymentMethodStep.tsx
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodsDisplay/PaymentMethodsDisplay.test.tsx
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodsDisplay/PaymentMethodsDisplay.tsx
  • apps/deploy-web/src/components/sdl/DeploymentMinimumEscrowAlertText.spec.tsx
  • apps/deploy-web/src/components/sdl/DeploymentMinimumEscrowAlertText.tsx
  • apps/deploy-web/src/context/PaymentPollingProvider/PaymentPollingProvider.spec.tsx
  • apps/deploy-web/src/context/WalletProvider/WalletProvider.spec.tsx
  • apps/deploy-web/src/context/WalletProvider/WalletProvider.tsx
  • apps/deploy-web/src/context/WalletProvider/index.ts
  • apps/deploy-web/src/hoc/guard/guard.hoc.tsx
  • apps/deploy-web/src/hooks/useHasFundingBanner.spec.ts
  • apps/deploy-web/src/hooks/useHasFundingBanner.ts
  • apps/deploy-web/src/hooks/useIsOnboarded.spec.ts
  • apps/deploy-web/src/hooks/useIsOnboarded.ts
  • apps/deploy-web/src/hooks/useManagedDeploymentConfirm.tsx
  • apps/deploy-web/src/hooks/useManagedWallet.ts
  • apps/deploy-web/src/hooks/useMintACT/useMintACT.spec.ts
  • apps/deploy-web/src/hooks/useMintACT/useMintACT.ts
  • apps/deploy-web/src/hooks/useOnboardingChrome.spec.ts
  • apps/deploy-web/src/hooks/useOnboardingChrome.ts
  • apps/deploy-web/src/hooks/useProviderCredentials/useProviderCredentials.spec.ts
  • apps/deploy-web/src/hooks/useProviderCredentials/useProviderCredentials.ts
  • apps/deploy-web/src/hooks/useProviderJwt/useProviderJwt.spec.tsx
  • apps/deploy-web/src/hooks/useProviderJwt/useProviderJwt.ts
  • apps/deploy-web/src/hooks/useWalletBalance.ts
  • apps/deploy-web/src/pages/billing/index.tsx
  • apps/deploy-web/src/pages/payment-methods/index.tsx
  • apps/deploy-web/src/pages/usage/index.tsx
  • apps/deploy-web/src/services/analytics/analytics.service.spec.ts
  • apps/deploy-web/src/services/analytics/analytics.service.ts
  • apps/deploy-web/src/store/walletStore.ts
  • apps/deploy-web/src/utils/TransactionMessageData.ts
  • apps/deploy-web/src/utils/apiUtils.ts
  • apps/deploy-web/src/utils/walletUtils.spec.ts
  • apps/deploy-web/src/utils/walletUtils.ts
  • apps/deploy-web/tests/seeders/localWallet.ts
  • apps/deploy-web/tests/seeders/wallet.ts
💤 Files with no reviewable changes (8)
  • apps/deploy-web/src/utils/apiUtils.ts
  • apps/deploy-web/src/hoc/guard/guard.hoc.tsx
  • apps/deploy-web/tests/seeders/localWallet.ts
  • apps/deploy-web/src/hooks/useMintACT/useMintACT.ts
  • apps/deploy-web/src/store/walletStore.ts
  • apps/deploy-web/src/hooks/useMintACT/useMintACT.spec.ts
  • apps/deploy-web/src/utils/walletUtils.spec.ts
  • apps/deploy-web/src/components/new-deployment/SdlBuilder.spec.tsx

Comment thread apps/deploy-web/src/components/deployments/DeploymentListRow.tsx Outdated
Comment thread apps/deploy-web/src/components/get-started/GetStartedStepper.tsx
Comment thread apps/deploy-web/src/hooks/useIsOnboarded.ts
Comment thread apps/deploy-web/src/utils/walletUtils.ts

@claude claude 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.

No bugs found, but this is an XL refactor of the shared wallet context (72 files) that changes app-wide boot-gating behavior (the boot overlay now blocks all pages, including public ones, for registered users until the wallet lookup settles) and removes several fields consumers relied on. Given the blast radius across billing/deployment flows and the behavioral change to boot sequencing, this is worth a human look.

Extended reasoning...

Overview

This PR completes a managed-wallet-only refactor: it slims the WalletProvider context API (removing isManaged, isWalletLoaded, isWalletLoading, isWalletInitializing, walletName, logout, isOnboarding, useIsManagedWalletUser), introduces a new boot gate that renders <BootLoading /> in place of children until the initial wallet-existence lookup settles, and deletes dead custodial-era code (ACT auto-mint path, useMintACT, Guard HOC, unused apiUtils builders, etc.). It touches 72 files across billing, deployment, and onboarding flows.

Security risks

No injection/auth/crypto surface is introduced. The gate change affects rendering/loading sequencing, not authorization — RequireAuth/route guards are unchanged. Wallet creation and signing paths are untouched aside from renaming (connectManagedWalletcreateWallet).

Level of scrutiny

This warrants more than a cursory pass: the WalletProvider boot gate now wraps the entire app in _app.tsx, including public pages, so its loading/settling behavior affects every page load for registered users. The PR also changes the public context shape consumed by ~15+ components, several of which had non-trivial conditional logic collapsed (e.g. AccountStatsCards, GetStartedStepper, DeploymentDepositModal's auto-mint removal). The bug-hunting system found no issues, and a candidate concern about the boot gate flashing/unmounting public pages for late-resolving registered users was investigated and refuted (the gate only engages when hasAuthenticatedUserId is true, so anonymous visitors on public pages are never blocked, and the check is against the current codebase which confirms WalletProvider wraps everything in _app.tsx).

Other factors

The PR includes solid test coverage (new WalletProvider.spec.tsx with 13 cases, and updates across ~20 other spec files), and the author's own verification notes (test/lint/type-check clean, manual smoke test) are thorough. However, the size (XL, 72 files), the fact it's stacked on another unmerged PR (#3563), and the app-wide behavioral change to boot sequencing are exactly the kind of large-scale, cross-cutting change where a second human reviewer's judgment adds value beyond automated checks.

…ltip

The Spent line pre-rounded to 2 decimals before PriceValue converts to USD,
so small spent amounts collapsed to $0.00 while the Balance line in the same
tooltip converts with full 6-decimal precision.
The balance step still keyed its readiness check on AKT/ACT minimum deposits
and pointed users at the Discord faucet, while the displayed amount only read
USDC. Managed credit is USD-pegged and can sit in USDC or ACT, so legacy
USDC-funded wallets saw the obsolete ACT warning and ACT-funded wallets saw
$0. Readiness and the displayed amount now both derive from the combined
USDC+ACT balance.
The suite was named .test.tsx, which vitest's include pattern never picks up,
and it still used Jest APIs, so it never ran and drifted from the component:
it asserted copy and button semantics that no longer exist. Renamed to
.spec.tsx, converted to vitest, and rewrote the drifted expectations against
the current component tree.
@baktun14

baktun14 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Addressed CodeRabbit's outside-diff note about Jest APIs in PaymentMethodsDisplay.test.tsx in eda0e0c, one step further than the suggestion: the .test.tsx suffix is not matched by vitest's include pattern (src/**/*.spec.{tsx,ts}), so the suite never ran and had drifted from the component (it asserted copy like "Payment Method Added" that no longer exists anywhere in src). Renamed it to .spec.tsx, converted it to vitest, and rewrote the drifted expectations against the current component tree; the 15 tests now run and pass.

@claude claude 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.

No bugs were found, but this PR is large in scope (73 files) and changes core wallet/session behavior — most notably adding a boot gate that shows a full-screen loading overlay on every page (including public ones) for registered users until the wallet lookup resolves. That's an app-wide UX and architectural change worth a human look before merging.

What was reviewed: the WalletProvider boot gate and its isInitializing/isWalletCreating derivation, the RequireOnboarding lease-based gate interaction with the new hasWallet field, the deposit modal's ACT/USD conversion after removing auto-mint, and the ~12 consumer sites that dropped isManaged/custodial branches.

Extended reasoning...

Overview

This PR completes a managed-wallet-only refactor across apps/deploy-web: it collapses the WalletProvider context (dropping isManaged, isWalletLoaded, isWalletLoading, walletName, logout, isOnboarding, etc. in favor of hasWallet/isWalletCreating/createWallet), introduces a boot gate that blocks rendering behind BootLoading until the initial wallet-existence lookup settles, removes the ACT auto-mint deposit flow and useMintACT, and strips now-dead custodial branches from ~12 consumers (GetStartedStepper, DeploymentListRow, ApiKeyList, AccountStatsCards/AccountHeader, CreateLease, useWalletBalance, etc.). It also removes the no-op Guard/useIsManagedWalletUser HOC from the billing/usage/payment-methods pages and deletes dead API URL builders and custodial analytics types.

Security risks

No injection, auth-bypass, or data-exposure concerns stood out — this is UI/state-management refactoring, not new data access or permission logic. The wallet-signing path (signAndBroadcastTx) and JWT generation (useProviderJwt) are unchanged in their security properties, just re-gated on hasWallet instead of isWalletConnected.

Level of scrutiny

This warrants a higher level of scrutiny than typical: it is an XL PR (73 files) that changes a cross-cutting app boot sequence — the new gate shows a full-screen loading overlay on every page, including public ones, for any registered user until v1/wallets resolves. That is an intentional, documented behavioral change, but it is exactly the kind of app-wide UX/architecture decision that benefits from a human sign-off rather than an automated approval, even though the bug-hunting pass came back clean.

Other factors

The PR has a new WalletProvider.spec.tsx (13 cases) covering the gate directly, and the author has already responded to and fixed all of CodeRabbit's findings (precision mismatch, duplicate type alias, obsolete ACT copy, incomplete test assertion) plus explained why the tri-state loading/error concern on useIsOnboarded does not apply. No outstanding unaddressed reviewer comments remain. Given the size and the app-wide gating change, a human review is still the safer path here.

@baktun14
baktun14 added this pull request to the merge queue Aug 7, 2026
Merged via the queue into main with commit 2ffacdc Aug 7, 2026
58 checks passed
@baktun14
baktun14 deleted the refactor/wallet-managed-only-context-boot-gate branch August 7, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants