Commit 815d633
authored
refactor(compliance): remove initial block wallets call (#8365)
## Explanation
This refactor removes the proactive bulk-fetch pattern from
`ComplianceController` and `ComplianceService`.
**Before:** On initialisation, `init()` eagerly fetched the full blocked
wallets list from `GET /v1/blocked-wallets` and persisted all addresses
in `state.blockedWallets`. This meant potentially thousands of
OFAC/sanctioned addresses were stored in client state, refreshed on a
configurable interval, and used as the primary lookup source for
`selectIsWalletBlocked`.
**After:** The controller only performs on-demand per-address API checks
(`checkWalletCompliance` / `checkWalletsCompliance`). Results are cached
in `walletComplianceStatusMap` keyed by address. If a subsequent API
call for the same address fails, the cached result is returned as a
fallback. If no cached result exists, the error is re-thrown.
### Changes
**`ComplianceController`**
- Removed `state.blockedWallets` and `state.blockedWalletsLastFetched`
fields
- Removed `init()`, `updateBlockedWallets()`, `#isBlockedWalletsStale()`
and `#blockedWalletsRefreshInterval`
- `checkWalletCompliance` and `checkWalletsCompliance` now wrap the API
call in try/catch — on failure they fall back to the per-address cache,
re-throwing only when no cached entry exists
**`ComplianceService`**
- Removed `updateBlockedWallets()` method and the `GET
/v1/blocked-wallets` endpoint integration
**`selectors`**
- `selectIsWalletBlocked` now reads solely from
`walletComplianceStatusMap`; the `selectBlockedWallets` intermediate
selector is removed
**`types`**
- Removed `BlockedWalletsInfo` type
**Messenger action types / index**
- Removed `ComplianceControllerInitAction`,
`ComplianceControllerUpdateBlockedWalletsAction`, and
`ComplianceServiceUpdateBlockedWalletsAction`
## References
N/A
## Checklist
- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [ ] I've communicated my changes to consumers by updating changelogs
for packages I've changed
- [ ] I've introduced breaking changes in this PR and have prepared
draft pull requests for clients and consumer packages to resolve them
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **High Risk**
> Breaking public API/state changes remove blocklist fetching and alter
`selectIsWalletBlocked` to depend solely on per-address cached checks,
which can change behavior when the API is down. Consumers must update
persisted-state migrations and remove calls to deleted
controller/service methods.
>
> **Overview**
> Removes the proactive full blocklist fetch/caching flow, shifting
compliance to **on-demand per-address checks** (`checkWalletCompliance`
/ `checkWalletsCompliance`) with a per-address cache used only as a
fallback when the API is unavailable.
>
> This is a **breaking change**: `ComplianceControllerState` drops
`blockedWallets`/`blockedWalletsLastFetched`, the controller’s
`init()`/`updateBlockedWallets()` methods and
`blockedWalletsRefreshInterval` option are removed, and
`ComplianceService:updateBlockedWallets` (and `GET /v1/blocked-wallets`)
plus related exported action/types (`BlockedWalletsInfo`, init/update
action types) are deleted. `selectIsWalletBlocked` now reads solely from
`walletComplianceStatusMap`, and tests/changelog are updated
accordingly.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
148c209. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 150a6ff commit 815d633
10 files changed
Lines changed: 249 additions & 616 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
12 | 21 | | |
13 | 22 | | |
14 | 23 | | |
| |||
Lines changed: 7 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | 8 | | |
19 | 9 | | |
20 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
21 | 13 | | |
22 | 14 | | |
23 | 15 | | |
| |||
29 | 21 | | |
30 | 22 | | |
31 | 23 | | |
32 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
33 | 28 | | |
34 | 29 | | |
35 | 30 | | |
| |||
39 | 34 | | |
40 | 35 | | |
41 | 36 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | 37 | | |
54 | 38 | | |
55 | 39 | | |
| |||
62 | 46 | | |
63 | 47 | | |
64 | 48 | | |
65 | | - | |
66 | 49 | | |
67 | 50 | | |
68 | | - | |
69 | 51 | | |
0 commit comments