@metamask/assets-controller 7.1.2 → 8.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -2
- package/dist/AssetsController.cjs +10 -1
- package/dist/AssetsController.cjs.map +1 -1
- package/dist/AssetsController.d.cts +2 -2
- package/dist/AssetsController.d.cts.map +1 -1
- package/dist/AssetsController.d.mts +2 -2
- package/dist/AssetsController.d.mts.map +1 -1
- package/dist/AssetsController.mjs +12 -3
- package/dist/AssetsController.mjs.map +1 -1
- package/dist/data-sources/AccountsApiDataSource.cjs +4 -1
- package/dist/data-sources/AccountsApiDataSource.cjs.map +1 -1
- package/dist/data-sources/AccountsApiDataSource.d.cts.map +1 -1
- package/dist/data-sources/AccountsApiDataSource.d.mts.map +1 -1
- package/dist/data-sources/AccountsApiDataSource.mjs +4 -1
- package/dist/data-sources/AccountsApiDataSource.mjs.map +1 -1
- package/dist/data-sources/SnapDataSource.cjs +4 -0
- package/dist/data-sources/SnapDataSource.cjs.map +1 -1
- package/dist/data-sources/SnapDataSource.d.cts +2 -2
- package/dist/data-sources/SnapDataSource.d.cts.map +1 -1
- package/dist/data-sources/SnapDataSource.d.mts +2 -2
- package/dist/data-sources/SnapDataSource.d.mts.map +1 -1
- package/dist/data-sources/SnapDataSource.mjs +4 -0
- package/dist/data-sources/SnapDataSource.mjs.map +1 -1
- package/dist/data-sources/TokenDataSource.cjs +7 -4
- package/dist/data-sources/TokenDataSource.cjs.map +1 -1
- package/dist/data-sources/TokenDataSource.d.cts +6 -0
- package/dist/data-sources/TokenDataSource.d.cts.map +1 -1
- package/dist/data-sources/TokenDataSource.d.mts +6 -0
- package/dist/data-sources/TokenDataSource.d.mts.map +1 -1
- package/dist/data-sources/TokenDataSource.mjs +6 -3
- package/dist/data-sources/TokenDataSource.mjs.map +1 -1
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [8.0.1]
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Add the previously declared `SnapControllerSnapInstalledEvent` to the `AssetsControllerMessenger` allowed events ([#8868](https://github.com/MetaMask/core/pull/8868))
|
|
15
|
+
- `addCustomAsset` now immediately seeds `assetsBalance` with a zero amount for the newly added asset, so the UI can render it before the next pipeline fetch ([#8872](https://github.com/MetaMask/core/pull/8872))
|
|
16
|
+
|
|
17
|
+
## [8.0.0]
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- Bump `@metamask/transaction-controller` from `^65.3.0` to `^66.0.0` ([#8796](https://github.com/MetaMask/core/pull/8796), [#8848](https://github.com/MetaMask/core/pull/8848))
|
|
22
|
+
- Bump `@metamask/core-backend` from `^6.2.2` to `^6.3.0` ([#8813](https://github.com/MetaMask/core/pull/8813))
|
|
23
|
+
- Bump `@metamask/phishing-controller` from `^17.1.2` to `^17.2.0` ([#8819](https://github.com/MetaMask/core/pull/8819))
|
|
24
|
+
- Bump `@metamask/network-enablement-controller` from `^5.1.1` to `^5.2.0` ([#8834](https://github.com/MetaMask/core/pull/8834))
|
|
25
|
+
- Bump `@metamask/polling-controller` from `^16.0.5` to `^16.0.6` ([#8834](https://github.com/MetaMask/core/pull/8834))
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
- `AccountsApiDataSource` no longer treats non-EVM chains (e.g. Solana) returned by the Accounts API as active chains; only `eip155:` networks are now included ([#8864](https://github.com/MetaMask/core/pull/8864))
|
|
30
|
+
- **BREAKING:** **SnapDataSource:** `SnapControllerSnapInstalledEvent` has been added to `SnapDataSourceAllowedEvents`. Hosts that restrict which events flow through the `AssetsController` messenger must now also delegate `SnapController:snapInstalled`; failing to do so will prevent snap chain re-discovery after install. Re-run keyring snap discovery when a new snap is installed so that snap-backed chains (Bitcoin, Solana, Tron, etc.) become available immediately after install ([#8862](https://github.com/MetaMask/core/pull/8862))
|
|
31
|
+
- Non-EVM assets with a `slip44` asset namespace (e.g. Bitcoin, Solana native, TRON) are now correctly typed as `native` instead of `erc20` in `assetsInfo` ([#8811](https://github.com/MetaMask/core/pull/8811))
|
|
32
|
+
- Solana SPL tokens (CAIP-19 `solana:.../token:<address>`) are now correctly typed as `spl` instead of `erc20` in `assetsInfo` ([#8811](https://github.com/MetaMask/core/pull/8811))
|
|
33
|
+
|
|
10
34
|
## [7.1.2]
|
|
11
35
|
|
|
12
36
|
### Changed
|
|
@@ -22,7 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
22
46
|
- `decimals: 0` is treated as valid; `name` and `symbol` are not required.
|
|
23
47
|
- Decimals resolution in `#handleBalanceUpdate` and the manual-fetch path no longer relies on `??` to fall through from state to pipeline metadata. A new `#pickValidDecimals` helper picks the first source whose `decimals` is finite and non-negative, so a stale `decimals: NaN` (or `decimals: -1`) in state can no longer shadow the chain-status stub's `decimals: 18` and silently produce `amount: '0'` while `assetsInfo` reports `decimals: 18`.
|
|
24
48
|
- `#convertToHumanReadable` now defensively returns `'0'` when `decimals` isn't a finite non-negative number or when the raw balance can't be parsed, matching the existing safe fallback used in the error path.
|
|
25
|
-
- The mUSD (`MetaMask USD`) contract address stored in `defaults.ts` is now EIP-55 checksummed (`0xacA92E438df0B2401fF60dA7E4337B687a2435DA`)
|
|
49
|
+
- The mUSD (`MetaMask USD`) contract address stored in `defaults.ts` is now EIP-55 checksummed (`0xacA92E438df0B2401fF60dA7E4337B687a2435DA`). Previously the address was all-lowercase, causing the CAIP-19 keys pre-seeded into `assetsInfo` by `buildDefaultAssetsInfo()` to differ from the checksummed keys written by data sources (which always normalise asset IDs via `normalizeAssetId`). The mismatch resulted in two separate `assetsInfo` entries for the same token after the first balance or token-data poll. ([#8786](https://github.com/MetaMask/core/pull/8786))
|
|
26
50
|
|
|
27
51
|
## [7.1.1]
|
|
28
52
|
|
|
@@ -497,7 +521,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
497
521
|
- Refactor `RpcDataSource` to delegate polling to `BalanceFetcher` and `TokenDetector` services ([#7709](https://github.com/MetaMask/core/pull/7709))
|
|
498
522
|
- Refactor `BalanceFetcher` and `TokenDetector` to extend `StaticIntervalPollingControllerOnly` for independent polling management ([#7709](https://github.com/MetaMask/core/pull/7709))
|
|
499
523
|
|
|
500
|
-
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@
|
|
524
|
+
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@8.0.1...HEAD
|
|
525
|
+
[8.0.1]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@8.0.0...@metamask/assets-controller@8.0.1
|
|
526
|
+
[8.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@7.1.2...@metamask/assets-controller@8.0.0
|
|
501
527
|
[7.1.2]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@7.1.1...@metamask/assets-controller@7.1.2
|
|
502
528
|
[7.1.1]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@7.1.0...@metamask/assets-controller@7.1.1
|
|
503
529
|
[7.1.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controller@7.0.1...@metamask/assets-controller@7.1.0
|
|
@@ -596,6 +596,7 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
596
596
|
const normalizedAssetId = (0, utils_2.normalizeAssetId)(assetId);
|
|
597
597
|
log('Adding custom asset', { accountId, assetId: normalizedAssetId });
|
|
598
598
|
this.update((state) => {
|
|
599
|
+
var _a;
|
|
599
600
|
const customAssets = state.customAssets;
|
|
600
601
|
if (!customAssets[accountId]) {
|
|
601
602
|
customAssets[accountId] = [];
|
|
@@ -619,7 +620,8 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
619
620
|
if (__classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_isNativeAsset).call(this, normalizedAssetId)) {
|
|
620
621
|
tokenType = 'native';
|
|
621
622
|
}
|
|
622
|
-
else if (parsed.
|
|
623
|
+
else if (parsed.chain.namespace === utils_1.KnownCaipNamespace.Solana &&
|
|
624
|
+
parsed.assetNamespace === TokenDataSource_1.CaipAssetNamespace.Token) {
|
|
623
625
|
tokenType = 'spl';
|
|
624
626
|
}
|
|
625
627
|
const assetMetadata = {
|
|
@@ -634,6 +636,11 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
634
636
|
state.assetsInfo[normalizedAssetId] =
|
|
635
637
|
assetMetadata;
|
|
636
638
|
}
|
|
639
|
+
// Seed a zero balance so the UI can render the asset immediately,
|
|
640
|
+
// before the next pipeline fetch returns the real amount.
|
|
641
|
+
const balances = state.assetsBalance;
|
|
642
|
+
balances[accountId] ?? (balances[accountId] = {});
|
|
643
|
+
(_a = balances[accountId])[normalizedAssetId] ?? (_a[normalizedAssetId] = { amount: '0' });
|
|
637
644
|
});
|
|
638
645
|
// Fetch data for the newly added custom asset (merge to preserve other chains)
|
|
639
646
|
const account = __classPrivateFieldGet(this, _AssetsController_instances, "m", _AssetsController_getSelectedAccounts).call(this).find((a) => a.id === accountId);
|
|
@@ -641,6 +648,8 @@ class AssetsController extends base_controller_1.BaseController {
|
|
|
641
648
|
const chainId = extractChainId(normalizedAssetId);
|
|
642
649
|
await this.getAssets([account], {
|
|
643
650
|
chainIds: [chainId],
|
|
651
|
+
dataTypes: ['balance', 'metadata', 'price'],
|
|
652
|
+
assetTypes: ['fungible'],
|
|
644
653
|
forceUpdate: true,
|
|
645
654
|
updateMode: 'merge',
|
|
646
655
|
});
|