Skip to content

Commit

Permalink
Merge branch 'main' into ad/remove-request-queue-toggleability
Browse files Browse the repository at this point in the history
  • Loading branch information
adonesky1 authored Nov 22, 2024
2 parents 8ecd45d + 1e23e90 commit d483359
Show file tree
Hide file tree
Showing 39 changed files with 587 additions and 642 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/core-monorepo",
"version": "253.0.0",
"version": "255.0.0",
"private": true,
"description": "Monorepo for packages shared between MetaMask clients",
"repository": {
Expand Down
14 changes: 13 additions & 1 deletion packages/accounts-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [20.0.0]

### Changed

- **BREAKING:** Bump peer dependency `@metamask/keyring-controller` from `^18.0.0` to `^19.0.0` ([#4915](https://github.com/MetaMask/core/pull/4956))
- **BREAKING:** Bump `@metamask/keyring-api` from `^8.1.3` to `^10.1.0` ([#4948](https://github.com/MetaMask/core/pull/4948))
- If you are depending on `@metamask/providers` directly, you will need to upgrade to `18.1.0`.
- Bump `@metamask/eth-snap-keyring` from `^4.3.6` to `^5.0.1` ([#4948](https://github.com/MetaMask/core/pull/4948))
- Bump `@metamask/snaps-utils` from `^4.3.6` to `^8.3.0` ([#4948](https://github.com/MetaMask/core/pull/4948))
- Bump `@metamask/snaps-sdk` from `^6.5.0` to `^6.7.0` ([#4948](https://github.com/MetaMask/core/pull/4948))

## [19.0.0]

### Changed
Expand Down Expand Up @@ -343,7 +354,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Initial release ([#1637](https://github.com/MetaMask/core/pull/1637))

[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/[email protected]
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/[email protected]
[20.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[19.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[18.2.3]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[18.2.2]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
Expand Down
8 changes: 4 additions & 4 deletions packages/accounts-controller/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/accounts-controller",
"version": "19.0.0",
"version": "20.0.0",
"description": "Manages internal accounts",
"keywords": [
"MetaMask",
Expand Down Expand Up @@ -61,7 +61,7 @@
},
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
"@metamask/keyring-controller": "^18.0.0",
"@metamask/keyring-controller": "^19.0.0",
"@metamask/snaps-controllers": "^9.10.0",
"@types/jest": "^27.4.1",
"@types/readable-stream": "^2.3.0",
Expand All @@ -72,8 +72,8 @@
"typescript": "~5.2.2"
},
"peerDependencies": {
"@metamask/keyring-controller": "^18.0.0",
"@metamask/snaps-controllers": "^9.10.0"
"@metamask/keyring-controller": "^19.0.0",
"@metamask/snaps-controllers": "^9.7.0"
},
"engines": {
"node": "^18.18 || >=20"
Expand Down
11 changes: 10 additions & 1 deletion packages/assets-controllers/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [45.0.0]

### Changed

- **BREAKING:** Bump `@metamask/keyring-controller` peer dependency from `^18.0.0` to `^19.0.0` ([#4195](https://github.com/MetaMask/core/pull/4956))
- **BREAKING:** Bump `@metamask/accounts-controller` peer dependency from `^19.0.0` to `^20.0.0` ([#4195](https://github.com/MetaMask/core/pull/4956))
- **BREAKING:** Bump `@metamask/preferences-controller` peer dependency from `^14.0.0` to `^15.0.0` ([#4195](https://github.com/MetaMask/core/pull/4956))

## [44.1.0]

### Changed
Expand Down Expand Up @@ -1244,7 +1252,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Use Ethers for AssetsContractController ([#845](https://github.com/MetaMask/core/pull/845))

[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/[email protected]
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/[email protected]
[45.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[44.1.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[44.0.1]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[44.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
Expand Down
14 changes: 7 additions & 7 deletions packages/assets-controllers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/assets-controllers",
"version": "44.1.0",
"version": "45.0.0",
"description": "Controllers which manage interactions involving ERC-20, ERC-721, and ERC-1155 tokens (including NFTs)",
"keywords": [
"MetaMask",
Expand Down Expand Up @@ -74,14 +74,14 @@
"uuid": "^8.3.2"
},
"devDependencies": {
"@metamask/accounts-controller": "^19.0.0",
"@metamask/accounts-controller": "^20.0.0",
"@metamask/approval-controller": "^7.1.1",
"@metamask/auto-changelog": "^3.4.4",
"@metamask/ethjs-provider-http": "^0.3.0",
"@metamask/keyring-api": "^10.1.0",
"@metamask/keyring-controller": "^18.0.0",
"@metamask/keyring-controller": "^19.0.0",
"@metamask/network-controller": "^22.0.2",
"@metamask/preferences-controller": "^14.0.0",
"@metamask/preferences-controller": "^15.0.0",
"@types/jest": "^27.4.1",
"@types/lodash": "^4.14.191",
"@types/node": "^16.18.54",
Expand All @@ -96,11 +96,11 @@
"typescript": "~5.2.2"
},
"peerDependencies": {
"@metamask/accounts-controller": "^19.0.0",
"@metamask/accounts-controller": "^20.0.0",
"@metamask/approval-controller": "^7.0.0",
"@metamask/keyring-controller": "^18.0.0",
"@metamask/keyring-controller": "^19.0.0",
"@metamask/network-controller": "^22.0.0",
"@metamask/preferences-controller": "^14.0.0"
"@metamask/preferences-controller": "^15.0.0"
},
"engines": {
"node": "^18.18 || >=20"
Expand Down
105 changes: 104 additions & 1 deletion packages/assets-controllers/src/TokenDetectionController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import {
} from '@metamask/controller-utils';
import type { InternalAccount } from '@metamask/keyring-api';
import type { KeyringControllerState } from '@metamask/keyring-controller';
import { getDefaultNetworkControllerState } from '@metamask/network-controller';
import {
getDefaultNetworkControllerState,
RpcEndpointType,
} from '@metamask/network-controller';
import type {
NetworkState,
NetworkConfiguration,
Expand Down Expand Up @@ -1014,6 +1017,7 @@ describe('TokenDetectionController', () => {
async ({
mockGetAccount,
mockTokenListGetState,
mockNetworkState,
triggerPreferencesStateChange,
triggerSelectedAccountChange,
callActionSpy,
Expand All @@ -1038,6 +1042,26 @@ describe('TokenDetectionController', () => {
},
},
});
mockNetworkState({
networkConfigurationsByChainId: {
'0x1': {
name: 'ethereum',
nativeCurrency: 'ETH',
rpcEndpoints: [
{
networkClientId: 'mainnet',
type: RpcEndpointType.Infura,
url: 'https://mainnet.infura.io/v3/{infuraProjectId}',
},
],
blockExplorerUrls: [],
chainId: '0x1',
defaultRpcEndpointIndex: 0,
},
},
networksMetadata: {},
selectedNetworkClientId: 'mainnet',
});

triggerPreferencesStateChange({
...getDefaultPreferencesState(),
Expand All @@ -1059,6 +1083,85 @@ describe('TokenDetectionController', () => {
);
});

it('should detect new tokens after switching between accounts on different chains', async () => {
const mockGetBalancesInSingleCall = jest.fn().mockResolvedValue({
[sampleTokenA.address]: new BN(1),
});
const firstSelectedAccount = createMockInternalAccount({
address: '0x0000000000000000000000000000000000000001',
});
const secondSelectedAccount = createMockInternalAccount({
address: '0x0000000000000000000000000000000000000002',
});
await withController(
{
options: {
disabled: false,
getBalancesInSingleCall: mockGetBalancesInSingleCall,
useAccountsAPI: true, // USING ACCOUNTS API
},
mocks: {
getSelectedAccount: firstSelectedAccount,
},
},
async ({
mockGetAccount,
mockTokenListGetState,
mockNetworkState,
triggerPreferencesStateChange,
triggerSelectedAccountChange,
controller,
}) => {
const mockTokens = jest.spyOn(controller, 'detectTokens');
mockMultiChainAccountsService();
mockTokenListGetState({
...getDefaultTokenListState(),
tokensChainsCache: {
'0x1': {
timestamp: 0,
data: {
[sampleTokenA.address]: {
name: sampleTokenA.name,
symbol: sampleTokenA.symbol,
decimals: sampleTokenA.decimals,
address: sampleTokenA.address,
occurrences: 1,
aggregators: sampleTokenA.aggregators,
iconUrl: sampleTokenA.image,
},
},
},
},
});
mockNetworkState({
...getDefaultNetworkControllerState(),
selectedNetworkClientId: NetworkType.mainnet,
});

triggerPreferencesStateChange({
...getDefaultPreferencesState(),
useTokenDetection: true,
});
mockGetAccount(secondSelectedAccount);
triggerSelectedAccountChange(secondSelectedAccount);

await advanceTime({ clock, duration: 1 });

expect(mockTokens).toHaveBeenNthCalledWith(1, {
chainIds: [
'0x1',
'0x5',
'0xaa36a7',
'0xe704',
'0xe705',
'0xe708',
],
selectedAddress: secondSelectedAccount.address,
});
},
);
});

it('should detect new tokens after enabling token detection', async () => {
const mockGetBalancesInSingleCall = jest.fn().mockResolvedValue({
[sampleTokenA.address]: new BN(1),
Expand Down
6 changes: 6 additions & 0 deletions packages/assets-controllers/src/TokenDetectionController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,12 +394,18 @@ export class TokenDetectionController extends StaticIntervalPollingController<To
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/no-misused-promises
async (selectedAccount) => {
const { networkConfigurationsByChainId } = this.messagingSystem.call(
'NetworkController:getState',
);

const chainIds = Object.keys(networkConfigurationsByChainId) as Hex[];
const isSelectedAccountIdChanged =
this.#selectedAccountId !== selectedAccount.id;
if (isSelectedAccountIdChanged) {
this.#selectedAccountId = selectedAccount.id;
await this.#restartTokenDetection({
selectedAddress: selectedAccount.address,
chainIds,
});
}
},
Expand Down
14 changes: 13 additions & 1 deletion packages/chain-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.2.0]

### Changed

- **BREAKING:** Bump `@metamask/keyring-api` from `^8.1.3` to `^10.1.0` ([#4948](https://github.com/MetaMask/core/pull/4948))
- If you are depending on `@metamask/providers` directly, you will need to upgrade to 18.1.0.
- Bump `@metamask/snaps-utils` from `^4.3.6` to `^8.3.0` ([#4948](https://github.com/MetaMask/core/pull/4948))
- Bump `@metamask/snaps-sdk` from `^6.5.0` to `^6.7.0` ([#4948](https://github.com/MetaMask/core/pull/4948))
- Bump `@metamask/snaps-controllers` from `^9.7.0`to `^9.10.0` ([#4948](https://github.com/MetaMask/core/pull/4948))
- Bump `@metamask/utils` from `^9.1.0` to `^10.0.0` ([#4831](https://github.com/MetaMask/core/pull/4831))

## [0.1.3]

### Changed
Expand Down Expand Up @@ -57,7 +68,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Initial release

[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/[email protected]
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/[email protected]
[0.2.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[0.1.3]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[0.1.2]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[0.1.1]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion packages/chain-controller/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/chain-controller",
"version": "0.1.3",
"version": "0.2.0",
"description": "Manages chain-agnostic providers",
"keywords": [
"MetaMask",
Expand Down
10 changes: 9 additions & 1 deletion packages/keyring-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [19.0.0]

### Changed

- **BREAKING:** Bump `@metamask/keyring-api` from `^8.1.3` to `^10.1.0` ([#4948](https://github.com/MetaMask/core/pull/4948))
- If you are depending on `@metamask/providers` directly, you will need to upgrade to 18.1.0.

## [18.0.0]

### Removed
Expand Down Expand Up @@ -581,7 +588,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

All changes listed after this point were applied to this package following the monorepo conversion.

[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/[email protected]
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/[email protected]
[19.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[18.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[17.3.1]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[17.3.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion packages/keyring-controller/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/keyring-controller",
"version": "18.0.0",
"version": "19.0.0",
"description": "Stores identities seen in the wallet and manages interactions such as signing",
"keywords": [
"MetaMask",
Expand Down
9 changes: 8 additions & 1 deletion packages/multichain/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

[Unreleased]: https://github.com/MetaMask/core/
## [1.0.0]

### Added

- Initial release ([#4962](https://github.com/MetaMask/core/pull/4962))

[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/[email protected]
[1.0.0]: https://github.com/MetaMask/core/releases/tag/@metamask/[email protected]
2 changes: 1 addition & 1 deletion packages/multichain/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/multichain",
"version": "0.0.0",
"version": "1.0.0",
"description": "Provides types, helpers, adapters, and wrappers for facilitating CAIP Multichain sessions",
"keywords": [
"MetaMask",
Expand Down
Loading

0 comments on commit d483359

Please sign in to comment.