Skip to content

Commit

Permalink
Merge branch 'main' into feat/accelerated-transaction-polling
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewwalsh0 authored Nov 20, 2024
2 parents 7692db0 + 73b9eb9 commit 65c46db
Show file tree
Hide file tree
Showing 102 changed files with 8,561 additions and 1,391 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": "252.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/accounts-controller@18.2.3...HEAD
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@19.0.0...HEAD
[19.0.0]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@18.2.3...@metamask/accounts-controller@19.0.0
[18.2.3]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@18.2.2...@metamask/accounts-controller@18.2.3
[18.2.2]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@18.2.1...@metamask/accounts-controller@18.2.2
[18.2.1]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@18.2.0...@metamask/accounts-controller@18.2.1
Expand Down
18 changes: 9 additions & 9 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 @@ -49,10 +49,10 @@
"dependencies": {
"@ethereumjs/util": "^8.1.0",
"@metamask/base-controller": "^7.0.2",
"@metamask/eth-snap-keyring": "^4.3.6",
"@metamask/keyring-api": "^8.1.3",
"@metamask/snaps-sdk": "^6.5.0",
"@metamask/snaps-utils": "^8.1.1",
"@metamask/eth-snap-keyring": "^5.0.1",
"@metamask/keyring-api": "^10.1.0",
"@metamask/snaps-sdk": "^6.7.0",
"@metamask/snaps-utils": "^8.3.0",
"@metamask/utils": "^10.0.0",
"deepmerge": "^4.2.2",
"ethereum-cryptography": "^2.1.2",
Expand All @@ -61,8 +61,8 @@
},
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
"@metamask/keyring-controller": "^17.3.1",
"@metamask/snaps-controllers": "^9.7.0",
"@metamask/keyring-controller": "^18.0.0",
"@metamask/snaps-controllers": "^9.10.0",
"@types/jest": "^27.4.1",
"@types/readable-stream": "^2.3.0",
"jest": "^27.5.1",
Expand All @@ -72,8 +72,8 @@
"typescript": "~5.2.2"
},
"peerDependencies": {
"@metamask/keyring-controller": "^17.0.0",
"@metamask/snaps-controllers": "^9.7.0"
"@metamask/keyring-controller": "^18.0.0",
"@metamask/snaps-controllers": "^9.10.0"
},
"engines": {
"node": "^18.18 || >=20"
Expand Down
2 changes: 1 addition & 1 deletion packages/accounts-controller/src/tests/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const createMockInternalAccount = ({
];
break;
case BtcAccountType.P2wpkh:
methods = [BtcMethod.SendMany];
methods = [BtcMethod.SendBitcoin];
break;
default:
throw new Error(`Unknown account type: ${type as string}`);
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
63 changes: 62 additions & 1 deletion packages/assets-controllers/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,61 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [44.1.0]

### Changed

- An argument `networkClientId` is added to `TokensController.ignoreTokens`, allowing tokens to be ignored on specific chains. ([#4949](https://github.com/MetaMask/core/pull/4949))

## [44.0.1]

### Changed

- Fixes an issue where the token detection was unnecessarily falling back to an RPC approach, causing redundant detections. ([#4928](https://github.com/MetaMask/core/pull/4928))

- Fixes an issue where `TokensController.addTokens` was not respecting the network client id passed to it. ([#4940](https://github.com/MetaMask/core/pull/4940))

## [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 +1244,13 @@ 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/assets-controllers@42.0.0...HEAD
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@44.1.0...HEAD
[44.1.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@44.0.1...@metamask/assets-controllers@44.1.0
[44.0.1]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@44.0.0...@metamask/assets-controllers@44.0.1
[44.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@43.1.1...@metamask/assets-controllers@44.0.0
[43.1.1]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@43.1.0...@metamask/assets-controllers@43.1.1
[43.1.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@43.0.0...@metamask/assets-controllers@43.1.0
[43.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@42.0.0...@metamask/assets-controllers@43.0.0
[42.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@41.0.0...@metamask/assets-controllers@42.0.0
[41.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@40.0.0...@metamask/assets-controllers@41.0.0
[40.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@39.0.0...@metamask/assets-controllers@40.0.0
Expand Down
21 changes: 11 additions & 10 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.1.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-api": "^10.1.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
Loading

0 comments on commit 65c46db

Please sign in to comment.