Skip to content

fix(managed-wallet): skip storage sync while wallet has no address#3512

Merged
baktun14 merged 1 commit into
mainfrom
fix/wallet-skip-storage-sync-without-address
Jul 24, 2026
Merged

fix(managed-wallet): skip storage sync while wallet has no address#3512
baktun14 merged 1 commit into
mainfrom
fix/wallet-skip-storage-sync-without-address

Conversation

@baktun14

@baktun14 baktun14 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Why

New trial users intermittently hit the Sentry warning Cannot create managed wallet entry without address, creditAmount and isTrialing (Sentry 7542732522). The API legitimately returns a wallet with a null address while trial provisioning is in flight (or after an interrupted provision), and the storage-sync effect in useManagedWallet tried to persist that address-less wallet on every render.

Fixes CON-743
Related to CON-744 (backend redesign that makes address-less wallets unobservable in API responses)

What

  • Skip the browser-storage sync in useManagedWallet while the wallet has no address — an address-less wallet can neither create a valid storage entry nor safely merge into an existing one.
  • Specs covering: address-less wallet is not persisted and does not clobber an existing entry; wallet with address is persisted; created wallet is persisted as selected.

Verified end-to-end against a local deploy-web with a mocked v1/wallets response: pre-fix the warning fires 4x on page load, post-fix zero, and with-address sync still writes the storage entry.

Summary by CodeRabbit

  • Bug Fixes

    • Improved managed wallet persistence by ignoring wallets without an address.
    • Preserved existing stored wallets when API responses lack an address.
    • Ensured wallets are saved with their latest balance and trial details once ready.
    • Newly created wallets are now correctly saved as the selected wallet.
  • Tests

    • Added coverage for wallet storage and persistence scenarios.

@coderabbitai

coderabbitai Bot commented Jul 23, 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: 7ad33a8a-dec8-4864-b535-48ba874ff7f6

📥 Commits

Reviewing files that changed from the base of the PR and between 4838598 and 85e3236.

📒 Files selected for processing (2)
  • apps/deploy-web/src/hooks/useManagedWallet.spec.tsx
  • apps/deploy-web/src/hooks/useManagedWallet.ts

📝 Walkthrough

Walkthrough

useManagedWallet now persists wallets only after an address is available. Tests cover incomplete API wallets, later address availability, and selecting successfully created wallets in storage.

Changes

Managed wallet persistence

Layer / File(s) Summary
Address-gated wallet synchronization
apps/deploy-web/src/hooks/useManagedWallet.ts
The storage effect returns when wallet.address is missing, while addressed wallets retain existing selected and non-selected persistence behavior.
Persistence behavior coverage
apps/deploy-web/src/hooks/useManagedWallet.spec.tsx
Tests model nullable API addresses and verify storage behavior for incomplete, addressed, and successfully created wallets using dynamic user data.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: 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 fix/wallet-skip-storage-sync-without-address

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.

ESLint install timed out. The project may have too many dependencies for the sandbox.


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

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.87%. Comparing base (757d28e) to head (85e3236).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3512      +/-   ##
==========================================
- Coverage   73.85%   72.87%   -0.99%     
==========================================
  Files        1139     1049      -90     
  Lines       29704    27357    -2347     
  Branches     7445     6986     -459     
==========================================
- Hits        21939    19937    -2002     
+ Misses       6854     6540     -314     
+ Partials      911      880      -31     
Flag Coverage Δ *Carryforward flag
api 86.50% <ø> (ø) Carriedforward from 757d28e
deploy-web 63.60% <100.00%> (+0.03%) ⬆️
log-collector ?
notifications 93.84% <ø> (ø) Carriedforward from 757d28e
provider-console 81.38% <ø> (ø) Carriedforward from 757d28e
provider-inventory ?
provider-proxy 88.17% <ø> (ø) Carriedforward from 757d28e
tx-signer ?

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

Files with missing lines Coverage Δ
apps/deploy-web/src/hooks/useManagedWallet.ts 93.54% <100.00%> (+24.58%) ⬆️

... and 91 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.

@baktun14
baktun14 added this pull request to the merge queue Jul 24, 2026
Merged via the queue into main with commit e2e6341 Jul 24, 2026
57 checks passed
@baktun14
baktun14 deleted the fix/wallet-skip-storage-sync-without-address branch July 24, 2026 14:42
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