Skip to content

refactor(compliance): remove initial block wallets call#8365

Merged
aganglada merged 4 commits intomainfrom
refactor/compliance-initi
Apr 2, 2026
Merged

refactor(compliance): remove initial block wallets call#8365
aganglada merged 4 commits intomainfrom
refactor/compliance-initi

Conversation

@aganglada
Copy link
Copy Markdown
Contributor

@aganglada aganglada commented Apr 1, 2026

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

  • I've updated the test suite for new or updated code as appropriate
  • 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

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.

Written by Cursor Bugbot for commit 148c209. This will update automatically on new commits. Configure here.

@aganglada aganglada self-assigned this Apr 1, 2026
@aganglada aganglada marked this pull request as ready for review April 1, 2026 20:49
@aganglada aganglada requested review from a team as code owners April 1, 2026 20:49
@aganglada aganglada enabled auto-merge April 1, 2026 22:19
@aganglada
Copy link
Copy Markdown
Contributor Author

For reviewers: Doesn't break any existing API as controller is not in production

Copy link
Copy Markdown
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Left a comment on the changelog, it's non-blocking though. Everything seems documented so that's what matters :) LGTM.

- The `updateBlockedWallets()` service method and its `GET /v1/blocked-wallets` endpoint integration have been removed.
- `ComplianceControllerInitAction`, `ComplianceControllerUpdateBlockedWalletsAction`, and `ComplianceServiceUpdateBlockedWalletsAction` types have been removed from the public API.
- The `BlockedWalletsInfo` type has been removed from the public API.
- `checkWalletCompliance` and `checkWalletsCompliance` now fall back to the per-address `walletComplianceStatusMap` cache when the API is unavailable, re-throwing only if no cached result exists for a requested address.
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.

Nit: Is this change or the next change breaking? It seems like only the removals would be breaking.

For clarity it might be helpful to split out the removals into their own entries. There is a separate "Removed" category you can use to highlight removals.

@aganglada aganglada added this pull request to the merge queue Apr 2, 2026
Merged via the queue into main with commit 815d633 Apr 2, 2026
332 checks passed
@aganglada aganglada deleted the refactor/compliance-initi branch April 2, 2026 15:42
@aganglada aganglada mentioned this pull request Apr 2, 2026
4 tasks
github-merge-queue bot pushed a commit that referenced this pull request Apr 2, 2026
## Explanation

This release bumps `@metamask/compliance-controller` from `1.0.2` to
`2.0.0`.

The major version bump is required due to breaking changes in the
compliance controller — see the
[changelog](https://github.com/MetaMask/core/blob/release/900.0.0/packages/compliance-controller/CHANGELOG.md)
for full details.

### Packages released

| Package | From | To | Type |
|---|---|---|---|
| `@metamask/compliance-controller` | `1.0.2` | `2.0.0` | major |

### Summary of changes

**Added**
- `generate-action-types` CLI tool available as a subpath export via the
`@metamask/messenger` bump
([#8264](#8264))

**Breaking changes**
- Removed proactive bulk-fetch pattern from `ComplianceController` and
`ComplianceService`
([#8365](#8365))
- `state.blockedWallets` and `state.blockedWalletsLastFetched` removed —
consumers with persisted state must drop these fields on migration
  - `init()`, `updateBlockedWallets()` controller methods removed
  - `blockedWalletsRefreshInterval` constructor option removed
- `ComplianceControllerInitAction`,
`ComplianceControllerUpdateBlockedWalletsAction`,
`ComplianceServiceUpdateBlockedWalletsAction`, `BlockedWalletsInfo`
removed from public API
- `checkWalletCompliance` / `checkWalletsCompliance` now fall back to
the per-address cache on API failure
- `selectIsWalletBlocked` now reads solely from
`walletComplianceStatusMap`

## References

- [#8365](#8365) —
refactor(compliance): remove initial block wallets call

## 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
- [x] I've communicated my changes to consumers by updating changelogs
for packages I've changed
- [x] 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]
> **Medium Risk**
> Release-only changes, but it publishes a new major
`@metamask/compliance-controller` version with breaking API/state
removals that downstream consumers must migrate to.
> 
> **Overview**
> Bumps the monorepo version to `900.0.0` and releases
`@metamask/compliance-controller` `2.0.0`.
> 
> Updates the compliance-controller changelog to document the
**breaking** removal of the blocked-wallets bulk-fetch flow and related
public API/state fields, and adjusts the `[Unreleased]`/`[2.0.0]`
compare links accordingly.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
7060084. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

---------

Co-authored-by: cryptodev-2s <109512101+cryptodev-2s@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants