Skip to content

Commit a4cd551

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix/AssetsAccountActivity
2 parents 19dfafb + a4d02be commit a4cd551

28 files changed

Lines changed: 430 additions & 61 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@metamask/core-monorepo",
3-
"version": "1156.0.0",
3+
"version": "1157.0.0",
44
"private": true,
55
"description": "Monorepo for packages shared between MetaMask clients",
66
"repository": {

packages/assets-controller/CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515

1616
- **BREAKING:** Remove `BackendWebsocketDataSource` and its factory/types (`BackendWebsocketDataSource`, `createBackendWebsocketDataSource`, `BackendWebsocketDataSourceOptions`, `BackendWebsocketDataSourceState`). Real-time balance updates and per-chain status are now consumed from `AccountActivityService` via `AccountActivityDataSource`, which manages the WebSocket connection and subscriptions. Consumers no longer need to delegate `BackendWebSocketService` actions/events to the `AssetsController` messenger ([#9517](https://github.com/MetaMask/core/pull/9517))
1717

18+
## [11.3.1]
19+
20+
### Changed
21+
22+
- Bump `@metamask/assets-controllers` from `^110.0.1` to `^110.0.2` ([#9706](https://github.com/MetaMask/core/pull/9706))
23+
- Bump `@metamask/network-enablement-controller` from `^5.6.0` to `^6.0.0` ([#9706](https://github.com/MetaMask/core/pull/9706))
24+
1825
## [11.3.0]
1926

2027
### Added
@@ -817,7 +824,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
817824
- Refactor `RpcDataSource` to delegate polling to `BalanceFetcher` and `TokenDetector` services ([#7709](https://github.com/MetaMask/core/pull/7709))
818825
- Refactor `BalanceFetcher` and `TokenDetector` to extend `StaticIntervalPollingControllerOnly` for independent polling management ([#7709](https://github.com/MetaMask/core/pull/7709))
819826

820-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@11.3.0...HEAD
827+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@11.3.1...HEAD
828+
[11.3.1]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@11.3.0...@metamask/assets-controller@11.3.1
821829
[11.3.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@11.2.1...@metamask/assets-controller@11.3.0
822830
[11.2.1]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@11.2.0...@metamask/assets-controller@11.2.1
823831
[11.2.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@11.1.1...@metamask/assets-controller@11.2.0

packages/assets-controller/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@metamask/assets-controller",
3-
"version": "11.3.0",
3+
"version": "11.3.1",
44
"description": "Tracks assets balances/prices and handles token detection across all digital assets",
55
"keywords": [
66
"Ethereum",
@@ -60,7 +60,7 @@
6060
"@ethersproject/providers": "^5.7.0",
6161
"@metamask/account-tree-controller": "^7.5.5",
6262
"@metamask/accounts-controller": "^39.0.5",
63-
"@metamask/assets-controllers": "^110.0.1",
63+
"@metamask/assets-controllers": "^110.0.2",
6464
"@metamask/base-controller": "^9.1.0",
6565
"@metamask/client-controller": "^1.0.1",
6666
"@metamask/controller-utils": "^12.3.0",
@@ -71,7 +71,7 @@
7171
"@metamask/keyring-snap-client": "^9.2.1",
7272
"@metamask/messenger": "^2.0.0",
7373
"@metamask/network-controller": "^34.0.0",
74-
"@metamask/network-enablement-controller": "^5.6.0",
74+
"@metamask/network-enablement-controller": "^6.0.0",
7575
"@metamask/permission-controller": "^13.1.1",
7676
"@metamask/phishing-controller": "^17.3.0",
7777
"@metamask/polling-controller": "^16.0.8",

packages/assets-controller/src/data-sources/AccountsApiDataSource.test.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,59 @@ describe('AccountsApiDataSource', () => {
937937
controller.destroy();
938938
});
939939

940+
it('subscribe update immediately fetches newly added chains', async () => {
941+
const { controller, assetsUpdateHandler } = await setupController();
942+
943+
await controller.subscribe({
944+
subscriptionId: 'sub-1',
945+
request: createDataRequest({ chainIds: [CHAIN_MAINNET] }),
946+
isUpdate: false,
947+
onAssetsUpdate: assetsUpdateHandler,
948+
});
949+
expect(assetsUpdateHandler).toHaveBeenCalledTimes(1);
950+
951+
const fetchSpy = jest.spyOn(controller, 'fetch');
952+
953+
// Simulate a chain handoff (e.g. websocket coverage dropped for Polygon).
954+
await controller.subscribe({
955+
subscriptionId: 'sub-1',
956+
request: createDataRequest({ chainIds: [CHAIN_MAINNET, CHAIN_POLYGON] }),
957+
isUpdate: true,
958+
onAssetsUpdate: assetsUpdateHandler,
959+
});
960+
961+
expect(fetchSpy).toHaveBeenCalledWith(
962+
expect.objectContaining({ chainIds: [CHAIN_POLYGON] }),
963+
);
964+
expect(assetsUpdateHandler).toHaveBeenCalledTimes(2);
965+
966+
controller.destroy();
967+
});
968+
969+
it('subscribe update does not fetch when no chains are added', async () => {
970+
const { controller, assetsUpdateHandler } = await setupController();
971+
972+
await controller.subscribe({
973+
subscriptionId: 'sub-1',
974+
request: createDataRequest({ chainIds: [CHAIN_MAINNET, CHAIN_POLYGON] }),
975+
isUpdate: false,
976+
onAssetsUpdate: assetsUpdateHandler,
977+
});
978+
expect(assetsUpdateHandler).toHaveBeenCalledTimes(1);
979+
980+
// Removing a chain (or an account-only update) should not trigger a fetch.
981+
await controller.subscribe({
982+
subscriptionId: 'sub-1',
983+
request: createDataRequest({ chainIds: [CHAIN_MAINNET] }),
984+
isUpdate: true,
985+
onAssetsUpdate: assetsUpdateHandler,
986+
});
987+
988+
expect(assetsUpdateHandler).toHaveBeenCalledTimes(1);
989+
990+
controller.destroy();
991+
});
992+
940993
describe('tokenDetectionEnabled', () => {
941994
async function setupControllerWithDetection(
942995
options: {

packages/assets-controller/src/data-sources/AccountsApiDataSource.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,8 +793,31 @@ export class AccountsApiDataSource extends AbstractDataSource<
793793
if (isUpdate) {
794794
const existing = this.activeSubscriptions.get(subscriptionId);
795795
if (existing) {
796+
const previousChains = existing.chains;
796797
existing.chains = chainsToSubscribe;
797798
existing.request = request;
799+
800+
// Chains handed off from another data source (e.g. the websocket
801+
// source releasing a chain that went down) would otherwise stay
802+
// stale until the next poll tick — fetch them immediately.
803+
const addedChains = chainsToSubscribe.filter(
804+
(chainId) => !previousChains.includes(chainId),
805+
);
806+
if (addedChains.length > 0) {
807+
try {
808+
const fetchResponse = await this.fetch({
809+
...request,
810+
chainIds: addedChains,
811+
});
812+
await existing.onAssetsUpdate(fetchResponse);
813+
} catch (error) {
814+
log('Initial fetch for added chains failed', {
815+
subscriptionId,
816+
addedChains,
817+
error,
818+
});
819+
}
820+
}
798821
return;
799822
}
800823
}

packages/assets-controllers/CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [110.0.2]
11+
12+
### Changed
13+
14+
- Bump `@metamask/network-enablement-controller` from `^5.6.0` to `^6.0.0` ([#9706](https://github.com/MetaMask/core/pull/9706))
15+
1016
## [110.0.1]
1117

1218
### Changed
@@ -3347,7 +3353,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
33473353
33483354
- Use Ethers for AssetsContractController ([#845](https://github.com/MetaMask/core/pull/845))
33493355
3350-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@110.0.1...HEAD
3356+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@110.0.2...HEAD
3357+
[110.0.2]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@110.0.1...@metamask/assets-controllers@110.0.2
33513358
[110.0.1]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@110.0.0...@metamask/assets-controllers@110.0.1
33523359
[110.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@109.4.1...@metamask/assets-controllers@110.0.0
33533360
[109.4.1]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@109.4.0...@metamask/assets-controllers@109.4.1

packages/assets-controllers/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@metamask/assets-controllers",
3-
"version": "110.0.1",
3+
"version": "110.0.2",
44
"description": "Controllers which manage interactions involving ERC-20, ERC-721, and ERC-1155 tokens (including NFTs)",
55
"keywords": [
66
"Ethereum",
@@ -76,7 +76,7 @@
7676
"@metamask/metamask-eth-abis": "^3.1.1",
7777
"@metamask/multichain-account-service": "^13.0.0",
7878
"@metamask/network-controller": "^34.0.0",
79-
"@metamask/network-enablement-controller": "^5.6.0",
79+
"@metamask/network-enablement-controller": "^6.0.0",
8080
"@metamask/permission-controller": "^13.1.1",
8181
"@metamask/phishing-controller": "^17.3.0",
8282
"@metamask/polling-controller": "^16.0.8",

packages/bridge-controller/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Changed
1111

12-
- Bump `@metamask/assets-controllers` from `^110.0.0` to `^110.0.1` ([#9693](https://github.com/MetaMask/core/pull/9693))
12+
- Bump `@metamask/assets-controllers` from `^110.0.0` to `^110.0.1` ([#9693](https://github.com/MetaMask/core/pull/9693), [#9706](https://github.com/MetaMask/core/pull/9706))
1313
- Bump `@metamask/transaction-controller` from `^69.2.1` to `^69.3.0` ([#9693](https://github.com/MetaMask/core/pull/9693))
14-
- Bump `@metamask/assets-controller` from `^11.2.1` to `^11.3.0` ([#9693](https://github.com/MetaMask/core/pull/9693))
14+
- Bump `@metamask/assets-controller` from `^11.2.1` to `^11.3.1` ([#9693](https://github.com/MetaMask/core/pull/9693), [#9706](https://github.com/MetaMask/core/pull/9706))
1515

1616
## [78.0.1]
1717

packages/bridge-controller/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060
"@ethersproject/contracts": "^5.7.0",
6161
"@ethersproject/providers": "^5.7.0",
6262
"@metamask/accounts-controller": "^39.0.5",
63-
"@metamask/assets-controller": "^11.3.0",
64-
"@metamask/assets-controllers": "^110.0.1",
63+
"@metamask/assets-controller": "^11.3.1",
64+
"@metamask/assets-controllers": "^110.0.2",
6565
"@metamask/base-controller": "^9.1.0",
6666
"@metamask/controller-utils": "^12.3.0",
6767
"@metamask/gas-fee-controller": "^26.3.0",

packages/client-utils/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Add `@metamask/slip44` dependency for native token symbol lookup ([#9701](https://github.com/MetaMask/core/pull/9701))
13+
14+
### Changed
15+
16+
- Restore native `assetId` on activity tokens and network fees when a symbol is available, using `@metamask/slip44` symbol lookup instead of the removed chain registry ([#9701](https://github.com/MetaMask/core/pull/9701))
17+
- Native tokens from indexed value transfers use the transfer symbol
18+
- Local native tokens and fees include slip44 `assetId` only when a native symbol is already present on the mapped data
19+
- API network fees derive the symbol from native value transfers when present
20+
- `assetId` is still omitted when no symbol is available (for example ERC-20-only transactions with no native transfer)
21+
1022
## [1.4.0]
1123

1224
### Added

0 commit comments

Comments
 (0)