Skip to content

Commit

Permalink
Merge branch 'main' into enable-nodejs-lint-rules-for-node-files
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmire committed Nov 15, 2024
2 parents 275e255 + 0f69373 commit 557c1a4
Show file tree
Hide file tree
Showing 101 changed files with 8,211 additions and 1,247 deletions.
6 changes: 3 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

## Notifications Team
/packages/notification-services-controller @MetaMask/notifications
/packages/profile-sync-controller @MetaMask/notifications

## Product Safety Team
/packages/phishing-controller @MetaMask/product-safety
Expand Down Expand Up @@ -60,6 +59,7 @@
/packages/permission-controller @MetaMask/wallet-api-platform-engineers @MetaMask/wallet-framework-engineers @MetaMask/snaps-devs
/packages/permission-log-controller @MetaMask/wallet-api-platform-engineers @MetaMask/wallet-framework-engineers
/packages/selected-network-controller @MetaMask/wallet-api-platform-engineers @MetaMask/wallet-framework-engineers @MetaMask/metamask-assets
/packages/profile-sync-controller @MetaMask/notifications @MetaMask/identity

## Package Release related
/packages/accounts-controller/package.json @MetaMask/accounts-engineers @MetaMask/wallet-framework-engineers
Expand Down Expand Up @@ -92,8 +92,8 @@
/packages/notification-services-controller/CHANGELOG.md @MetaMask/notifications @MetaMask/wallet-framework-engineers
/packages/phishing-controller/package.json @MetaMask/product-safety @MetaMask/wallet-framework-engineers
/packages/phishing-controller/CHANGELOG.md @MetaMask/product-safety @MetaMask/wallet-framework-engineers
/packages/profile-sync-controller/package.json @MetaMask/notifications @MetaMask/wallet-framework-engineers
/packages/profile-sync-controller/CHANGELOG.md @MetaMask/notifications @MetaMask/wallet-framework-engineers
/packages/profile-sync-controller/package.json @MetaMask/notifications @MetaMask/identity @MetaMask/wallet-framework-engineers
/packages/profile-sync-controller/CHANGELOG.md @MetaMask/notifications @MetaMask/identity @MetaMask/wallet-framework-engineers
/packages/queued-request-controller/package.json @MetaMask/wallet-api-platform-engineers @MetaMask/wallet-framework-engineers
/packages/queued-request-controller/CHANGELOG.md @MetaMask/wallet-api-platform-engineers @MetaMask/wallet-framework-engineers
/packages/signature-controller/package.json @MetaMask/confirmations @MetaMask/wallet-framework-engineers
Expand Down
29 changes: 18 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,21 @@

This monorepo is a collection of packages used across multiple MetaMask clients (e.g. [`metamask-extension`](https://github.com/MetaMask/metamask-extension/), [`metamask-mobile`](https://github.com/MetaMask/metamask-mobile/)).

## Modules
## Contributing

This repository contains the following packages [^fn1]:
See the [Contributor Guide](./docs/contributing.md) for help on:

- Setting up your development environment
- Working with the monorepo
- Testing changes in clients
- Issuing new releases
- Creating a new package

## Installation/Usage

Each package in this repository has its own README where you can find installation and usage instructions. See `packages/` for more.

## Packages

<!-- start package list -->

Expand Down Expand Up @@ -46,8 +58,6 @@ This repository contains the following packages [^fn1]:

<!-- end package list -->

Or, in graph form [^fn1]:

<!-- start dependency graph -->

```mermaid
Expand Down Expand Up @@ -122,6 +132,9 @@ linkStyle default opacity:0.5
logging_controller --> controller_utils;
message_manager --> base_controller;
message_manager --> controller_utils;
multichain --> controller_utils;
multichain --> network_controller;
multichain --> permission_controller;
name_controller --> base_controller;
name_controller --> controller_utils;
network_controller --> base_controller;
Expand Down Expand Up @@ -185,10 +198,4 @@ linkStyle default opacity:0.5

<!-- end dependency graph -->

Refer to individual packages for usage instructions.

## Learn more

For instructions on performing common development-related tasks, see [contributing to the monorepo](./docs/contributing.md).

[^fn1]: The package list and dependency graph should be programmatically generated by running `yarn update-readme-content`.
(This section may be regenerated at any time by running `yarn update-readme-content`.)
211 changes: 116 additions & 95 deletions docs/contributing.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/example-controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
},
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
"@metamask/controller-utils": "^11.4.2",
"@metamask/controller-utils": "^11.4.3",
"@types/jest": "^27.4.1",
"deepmerge": "^4.2.2",
"jest": "^27.5.1",
Expand Down
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": "244.0.0",
"version": "248.0.0",
"private": true,
"description": "Monorepo for packages shared between MetaMask clients",
"repository": {
Expand Down
9 changes: 8 additions & 1 deletion packages/accounts-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [19.0.0]

### Changed

- **BREAKING:** Bump peer dependency `@metamask/keyring-controller` from `^17.0.0` to `^18.0.0` ([#4915](https://github.com/MetaMask/core/pull/4915))

## [18.2.3]

### Changed
Expand Down Expand Up @@ -337,7 +343,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]
[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]
[18.2.1]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
Expand Down
6 changes: 3 additions & 3 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": "18.2.3",
"version": "19.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": "^17.3.1",
"@metamask/keyring-controller": "^18.0.0",
"@metamask/snaps-controllers": "^9.7.0",
"@types/jest": "^27.4.1",
"@types/readable-stream": "^2.3.0",
Expand All @@ -72,7 +72,7 @@
"typescript": "~5.2.2"
},
"peerDependencies": {
"@metamask/keyring-controller": "^17.0.0",
"@metamask/keyring-controller": "^18.0.0",
"@metamask/snaps-controllers": "^9.7.0"
},
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion packages/address-book-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
},
"dependencies": {
"@metamask/base-controller": "^7.0.2",
"@metamask/controller-utils": "^11.4.2",
"@metamask/controller-utils": "^11.4.3",
"@metamask/utils": "^10.0.0"
},
"devDependencies": {
Expand Down
47 changes: 46 additions & 1 deletion packages/assets-controllers/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,47 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [44.0.0]

### Changed

- **BREAKING**: The `TokenBalancesController` state is now across all chains and accounts under the field `tokenBalances`, as a mapping from account address -> chain id -> token address -> balance. ([#4782](https://github.com/MetaMask/core/pull/4782))

- **BREAKING**: The `TokenBalancesController` now extends `StaticIntervalPollingController`, and the new polling API `startPolling` must be used to initiate polling (`startPolling`, `stopPollingByPollingToken`). ([#4782](https://github.com/MetaMask/core/pull/4782))

- **BREAKING**: `TokenBalancesController` now requires subscriptions to the `PreferencesController:stateChange` and `NetworkController:stateChange` events. And access to the `NetworkController:getNetworkClientById`, `NetworkController:getState`, `TokensController:getState`, and `PreferencesController:getState` actions. ([#4782](https://github.com/MetaMask/core/pull/4782))

- **BREAKING**: `TokensController` requires a subscription to the `NetworkController:stateChange` event. It now now removes state for chain IDs when their network is removed. ([#4782](https://github.com/MetaMask/core/pull/4782))

- `TokenRatesController` now removes state for chain IDs when their network is removed. ([#4782](https://github.com/MetaMask/core/pull/4782))

## [43.1.1]

### Changed

- Fix a bug in `TokensController.addTokens` where tokens could be added from the wrong chain. ([#4924](https://github.com/MetaMask/core/pull/4924))

## [43.1.0]

### Added

- Add Solana to the polled exchange rates ([#4914](https://github.com/MetaMask/core/pull/4914))

## [43.0.0]

### Added

- `AccountTrackerController` now tracks balances of staked ETH for each account, under the state property `stakedBalance`. ([#4879](https://github.com/MetaMask/core/pull/4879))

### Changed

- **BREAKING**: The polling input for`TokenListController` is now `{chainId: Hex}` instead of `{networkClientId: NetworkClientId}`. ([#4878](https://github.com/MetaMask/core/pull/4878))
- **BREAKING**: The polling input for`TokenDetectionController` is now `{ chainIds: Hex[]; address: string; }` instead of `{ networkClientId: NetworkClientId; address: string; }`. ([#4894](https://github.com/MetaMask/core/pull/4894))
- **BREAKING:** Bump `@metamask/keyring-controller` peer dependency from `^17.0.0` to `^18.0.0` ([#4195](https://github.com/MetaMask/core/pull/4195))
- **BREAKING:** Bump `@metamask/preferences-controller` peer dependency from `^13.2.0` to `^14.0.0` ([#4909](https://github.com/MetaMask/core/pull/4909), [#4915](https://github.com/MetaMask/core/pull/4915))
- **BREAKING:** Bump `@metamask/accounts-controller` peer dependency from `^18.0.0` to `^19.0.0` ([#4915](https://github.com/MetaMask/core/pull/4915))
- Bump `@metamask/controller-utils` from `^11.4.2` to `^11.4.3` ([#4195](https://github.com/MetaMask/core/pull/4195))

## [42.0.0]

### Added
Expand Down Expand Up @@ -1189,7 +1230,11 @@ 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]
[44.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[43.1.1]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[43.1.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[43.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[42.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[41.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
[40.0.0]: https://github.com/MetaMask/core/compare/@metamask/[email protected]...@metamask/[email protected]
Expand Down
19 changes: 10 additions & 9 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": "42.0.0",
"version": "44.0.0",
"description": "Controllers which manage interactions involving ERC-20, ERC-721, and ERC-1155 tokens (including NFTs)",
"keywords": [
"MetaMask",
Expand Down Expand Up @@ -48,14 +48,15 @@
},
"dependencies": {
"@ethereumjs/util": "^8.1.0",
"@ethersproject/abi": "^5.7.0",
"@ethersproject/address": "^5.7.0",
"@ethersproject/bignumber": "^5.7.0",
"@ethersproject/contracts": "^5.7.0",
"@ethersproject/providers": "^5.7.0",
"@metamask/abi-utils": "^2.0.3",
"@metamask/base-controller": "^7.0.2",
"@metamask/contract-metadata": "^2.4.0",
"@metamask/controller-utils": "^11.4.2",
"@metamask/controller-utils": "^11.4.3",
"@metamask/eth-query": "^4.0.0",
"@metamask/metamask-eth-abis": "^3.1.1",
"@metamask/polling-controller": "^12.0.1",
Expand All @@ -73,14 +74,14 @@
"uuid": "^8.3.2"
},
"devDependencies": {
"@metamask/accounts-controller": "^18.2.3",
"@metamask/accounts-controller": "^19.0.0",
"@metamask/approval-controller": "^7.1.1",
"@metamask/auto-changelog": "^3.4.4",
"@metamask/ethjs-provider-http": "^0.3.0",
"@metamask/keyring-api": "^8.1.3",
"@metamask/keyring-controller": "^17.3.1",
"@metamask/network-controller": "^22.0.1",
"@metamask/preferences-controller": "^13.3.0",
"@metamask/keyring-controller": "^18.0.0",
"@metamask/network-controller": "^22.0.2",
"@metamask/preferences-controller": "^14.0.0",
"@types/jest": "^27.4.1",
"@types/lodash": "^4.14.191",
"@types/node": "^16.18.54",
Expand All @@ -95,11 +96,11 @@
"typescript": "~5.2.2"
},
"peerDependencies": {
"@metamask/accounts-controller": "^18.0.0",
"@metamask/accounts-controller": "^19.0.0",
"@metamask/approval-controller": "^7.0.0",
"@metamask/keyring-controller": "^17.0.0",
"@metamask/keyring-controller": "^18.0.0",
"@metamask/network-controller": "^22.0.0",
"@metamask/preferences-controller": "^13.0.0"
"@metamask/preferences-controller": "^14.0.0"
},
"engines": {
"node": "^18.18 || >=20"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,14 @@ describe('RatesController', () => {
const { fiatCurrency, rates, cryptocurrencies } = ratesController.state;
expect(ratesController).toBeDefined();
expect(fiatCurrency).toBe('usd');
expect(Object.keys(rates)).toStrictEqual([Cryptocurrency.Btc]);
expect(cryptocurrencies).toStrictEqual([Cryptocurrency.Btc]);
expect(Object.keys(rates)).toStrictEqual([
Cryptocurrency.Btc,
Cryptocurrency.Solana,
]);
expect(cryptocurrencies).toStrictEqual([
Cryptocurrency.Btc,
Cryptocurrency.Solana,
]);
});
});

Expand All @@ -119,11 +125,16 @@ describe('RatesController', () => {
const publishActionSpy = jest.spyOn(messenger, 'publish');

jest.spyOn(global.Date, 'now').mockImplementation(() => getStubbedDate());
const mockRateValue = 57715.42;
const mockBtcRateValue = 57715.42;
const mockSolRateValue = 200.48;

const fetchExchangeRateStub = jest.fn(() => {
return Promise.resolve({
btc: {
eur: mockRateValue,
eur: mockBtcRateValue,
},
sol: {
eur: mockSolRateValue,
},
});
});
Expand All @@ -144,6 +155,10 @@ describe('RatesController', () => {
conversionDate: 0,
conversionRate: 0,
},
sol: {
conversionDate: 0,
conversionRate: 0,
},
});

await ratesController.start();
Expand All @@ -163,7 +178,11 @@ describe('RatesController', () => {
expect(ratesPosUpdate).toStrictEqual({
btc: {
conversionDate: MOCK_TIMESTAMP,
conversionRate: mockRateValue,
conversionRate: mockBtcRateValue,
},
sol: {
conversionDate: MOCK_TIMESTAMP,
conversionRate: mockSolRateValue,
},
});

Expand Down Expand Up @@ -326,7 +345,10 @@ describe('RatesController', () => {

const cryptocurrencyListPreUpdate =
ratesController.getCryptocurrencyList();
expect(cryptocurrencyListPreUpdate).toStrictEqual([Cryptocurrency.Btc]);
expect(cryptocurrencyListPreUpdate).toStrictEqual([
Cryptocurrency.Btc,
Cryptocurrency.Solana,
]);
// Just to make sure we're updating to something else than the default list
expect(cryptocurrencyListPreUpdate).not.toStrictEqual(
mockCryptocurrencyList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ import type {

export const name = 'RatesController';

/**
* Supported cryptocurrencies that can be used as a base currency. The value needs to be compatible
* with CryptoCompare's API which is the default source for the rates.
*
* See: https://min-api.cryptocompare.com/documentation?key=Price&cat=multipleSymbolsPriceEndpoint
*/
export enum Cryptocurrency {
Btc = 'btc',
Solana = 'sol',
}

const DEFAULT_INTERVAL = 180000;
Expand All @@ -31,8 +38,12 @@ const defaultState = {
conversionDate: 0,
conversionRate: 0,
},
[Cryptocurrency.Solana]: {
conversionDate: 0,
conversionRate: 0,
},
},
cryptocurrencies: [Cryptocurrency.Btc],
cryptocurrencies: [Cryptocurrency.Btc, Cryptocurrency.Solana],
};

export class RatesController extends BaseController<
Expand Down
Loading

0 comments on commit 557c1a4

Please sign in to comment.