Skip to content

Commit

Permalink
Merge branch '231220-TokensController-v2-migration' into 230129-token…
Browse files Browse the repository at this point in the history
…-detection-controller-merge-tests
  • Loading branch information
MajorLift committed Feb 8, 2024
2 parents 5bb296b + a386301 commit a89ad4a
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 122 deletions.
7 changes: 0 additions & 7 deletions constraints.pro
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,3 @@ gen_enforced_field(WorkspaceCwd, 'publishConfig.registry', 'https://registry.npm
% whatsoever.
gen_enforced_field(WorkspaceCwd, 'publishConfig', null) :-
workspace_field(WorkspaceCwd, 'private', true).

% eth-method-registry has an unlisted dependency on babel-runtime (via `ethjs->ethjs-query`), so
% that package needs to be present if eth-method-registry is present.
gen_enforced_dependency(WorkspaceCwd, 'babel-runtime', '^6.26.0', 'peerDependencies') :-
workspace_has_dependency(WorkspaceCwd, 'eth-method-registry', _, 'dependencies').
gen_enforced_dependency(WorkspaceCwd, 'babel-runtime', '^6.26.0', 'devDependencies') :-
workspace_has_dependency(WorkspaceCwd, 'eth-method-registry', _, 'dependencies').
5 changes: 2 additions & 3 deletions packages/assets-controllers/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- **BREAKING:** Adds `@metamask/accounts-controller` ^8.0.0 and `@metamask/keyring-controller` ^12.0.0 as dependencies and peer dependencies. ([#3775](https://github.com/MetaMask/core/pull/3775/)).
- Adds `@metamask/keyring-api` ^3.0.0 as a devDependency. ([#3775](https://github.com/MetaMask/core/pull/3775/))
- `TokenDetectionController` newly subscribes to the `PreferencesController:stateChange`, `AccountsController:selectedAccountChange`, `KeyringController:lock`, `KeyringController:unlock` events, and allows the `PreferencesController:getState` messenger action. ([#3775](https://github.com/MetaMask/core/pull/3775/))
- **BREAKING:** `TokenDetectionController` newly subscribes to the `PreferencesController:stateChange`, `AccountsController:selectedAccountChange`, `KeyringController:lock`, `KeyringController:unlock` events, and allows the `PreferencesController:getState` messenger action. ([#3775](https://github.com/MetaMask/core/pull/3775/))
- `TokensController` now exports `TokensControllerActions`, `TokensControllerGetStateAction`, `TokensControllerAddDetectedTokensAction`, `TokensControllerEvents`, `TokensControllerStateChangeEvent`. ([#3690](https://github.com/MetaMask/core/pull/3690/))

### Changed

- **BREAKING:** `TokenDetectionController` is merged with `DetectTokensController` from the `metamask-extension` repo. ([#3775](https://github.com/MetaMask/core/pull/3775/))
- **BREAKING:** `TokenDetectionController` now resets its polling interval to the default value of 3 minutes when token detection is triggered by external controller events `KeyringController:unlock`, `TokenListController:stateChange`, `PreferencesController:stateChange`, `AccountsController:selectedAccountChange`.
- **BREAKING:** `TokenDetectionController` now responds to `NetworkController:networkDidChange` event only if the `networkClientId` is changed, and does not reset the polling interval in this case.
- **BREAKING:** `TokenDetectionController` now refetches tokens on `NetworkController:networkDidChange` if the `networkClientId` is changed instead of `chainId`.
- **BREAKING:** `TokenDetectionController` cannot initiate polling or token detection if `KeyringController` state is locked.
- **BREAKING:** The `detectTokens` method now excludes tokens that are already included in the `TokensController`'s `detectedTokens` list from the batch of incoming tokens it sends to the `TokensController` `addDetectedTokens` method.
- **BREAKING:** The constructor for `TokenDetectionController` expects a new required proprerty `trackMetaMetricsEvent`, which defines the callback that is called in the `detectTokens` method.
Expand Down
2 changes: 1 addition & 1 deletion packages/assets-controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
},
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
"@metamask/ethjs-provider-http": "^0.2.0",
"@metamask/ethjs-provider-http": "^0.3.0",
"@metamask/keyring-api": "^3.0.0",
"@types/jest": "^27.4.1",
"@types/lodash": "^4.14.191",
Expand Down
2 changes: 1 addition & 1 deletion packages/controller-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"dependencies": {
"@metamask/eth-query": "^4.0.0",
"@metamask/ethjs-unit": "^0.2.1",
"@metamask/ethjs-unit": "^0.3.0",
"@metamask/utils": "^8.3.0",
"@spruceid/siwe-parser": "1.1.3",
"eth-ens-namehash": "^2.0.8",
Expand Down
2 changes: 1 addition & 1 deletion packages/gas-fee-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@metamask/base-controller": "^4.1.1",
"@metamask/controller-utils": "^8.0.2",
"@metamask/eth-query": "^4.0.0",
"@metamask/ethjs-unit": "^0.2.1",
"@metamask/ethjs-unit": "^0.3.0",
"@metamask/network-controller": "^17.2.0",
"@metamask/polling-controller": "^5.0.0",
"@metamask/utils": "^8.3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,9 @@ export class SelectedNetworkController extends BaseController<
this.#setNetworkClientIdForDomain(domain, networkClientId);
}

getNetworkClientIdForDomain(domain: Domain) {
getNetworkClientIdForDomain(domain: Domain): NetworkClientId {
if (this.state.perDomainNetwork) {
return this.state.domains[domain];
return this.state.domains[domain] ?? this.state.domains[METAMASK_DOMAIN];
}
return this.state.domains[METAMASK_DOMAIN];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,18 @@ describe('SelectedNetworkController', () => {
expect(result1).toBe(networkClientId1);
expect(result2).toBe(networkClientId2);
});

it('returns the networkClientId for the metamask domain, when the perDomainNetwork option is true, but no networkClientId has been set for the domain requested', () => {
const options: SelectedNetworkControllerOptions = {
messenger: buildSelectedNetworkControllerMessenger(),
};
const controller = new SelectedNetworkController(options);
controller.state.perDomainNetwork = true;
const networkClientId = 'network7';
controller.setNetworkClientIdForMetamask(networkClientId);
const result = controller.getNetworkClientIdForDomain('example.com');
expect(result).toBe(networkClientId);
});
});

describe('getProviderAndBlockTracker', () => {
Expand Down
10 changes: 5 additions & 5 deletions packages/transaction-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@
"@metamask/rpc-errors": "^6.1.0",
"@metamask/utils": "^8.3.0",
"async-mutex": "^0.2.6",
"eth-method-registry": "^3.0.0",
"eth-method-registry": "^4.0.0",
"ethereumjs-util": "^7.0.10",
"fast-json-patch": "^3.1.1",
"lodash": "^4.17.21",
"nonce-tracker": "^3.0.0",
"uuid": "^8.3.2"
},
"devDependencies": {
"@babel/runtime": "^7.23.9",
"@metamask/auto-changelog": "^3.4.4",
"@metamask/ethjs-provider-http": "^0.2.0",
"@metamask/ethjs-provider-http": "^0.3.0",
"@types/jest": "^27.4.1",
"@types/node": "^16.18.54",
"babel-runtime": "^6.26.0",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
"sinon": "^9.2.4",
Expand All @@ -66,10 +66,10 @@
"typescript": "~4.8.4"
},
"peerDependencies": {
"@babel/runtime": "^7.23.9",
"@metamask/approval-controller": "^5.1.2",
"@metamask/gas-fee-controller": "^13.0.0",
"@metamask/network-controller": "^17.2.0",
"babel-runtime": "^6.26.0"
"@metamask/network-controller": "^17.2.0"
},
"engines": {
"node": ">=16.0.0"
Expand Down
Loading

0 comments on commit a89ad4a

Please sign in to comment.