Skip to content

Commit

Permalink
Merge branch 'main' into 3747-update-abstractmessagemanager-to-baseco…
Browse files Browse the repository at this point in the history
…ntrollerv2
  • Loading branch information
OGPoyraz authored Jan 6, 2025
2 parents b5baa28 + e825794 commit 925e9fd
Show file tree
Hide file tree
Showing 104 changed files with 3,665 additions and 1,344 deletions.
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
/packages/rate-limit-controller @MetaMask/snaps-devs

## Wallet API Platform Team
/packages/multichain @MetaMask/wallet-api-platform-engineers
/packages/queued-request-controller @MetaMask/wallet-api-platform-engineers

## Wallet Framework Team
Expand Down Expand Up @@ -90,6 +91,8 @@
/packages/phishing-controller/CHANGELOG.md @MetaMask/product-safety @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/multichain/package.json @MetaMask/wallet-api-platform-engineers @MetaMask/wallet-framework-engineers
/packages/multichain/CHANGELOG.md @MetaMask/wallet-api-platform-engineers @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
10 changes: 7 additions & 3 deletions .github/workflows/create-update-issues.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ jobs:
# Check if version number ends with .0.0
if [[ $version == *.0.0 ]]; then
# Fetch responsible team from file
# Fetch responsible teams from file
teams=$(jq -r --arg key "$package_name" '.[$key]' teams.json)
gh issue create --title "Update ${package_name} to version ${version}" --body "Please update ${package_name} to version ${version}" --repo "MetaMask/metamask-extension" --label "$teams, client-controller-update"
gh issue create --title "Update ${package_name} to version ${version}" --body "Please update ${package_name} to version ${version}" --repo "MetaMask/metamask-mobile" --label "$teams, client-controller-update"
labels="client-controller-update"
if [[ $teams != "null" ]]; then
labels+=",$teams"
fi
gh issue create --title "Update ${package_name} to version ${version}" --body "Please update ${package_name} to version ${version}" --repo "MetaMask/metamask-extension" --label "$labels"
gh issue create --title "Update ${package_name} to version ${version}" --body "Please update ${package_name} to version ${version}" --repo "MetaMask/metamask-mobile" --label "$labels"
fi
fi
done
Expand Down
4 changes: 2 additions & 2 deletions examples/example-controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
},
"dependencies": {
"@metamask/base-controller": "^7.0.2",
"@metamask/utils": "^10.0.0"
"@metamask/base-controller": "^7.1.0",
"@metamask/utils": "^11.0.1"
},
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
Expand Down
14 changes: 9 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metamask/core-monorepo",
"version": "271.0.0",
"version": "275.0.0",
"private": true,
"description": "Monorepo for packages shared between MetaMask clients",
"repository": {
Expand All @@ -20,12 +20,13 @@
"changelog:update": "yarn workspaces foreach --all --no-private --parallel --interlaced --verbose run changelog:update",
"changelog:validate": "yarn workspaces foreach --all --no-private --parallel --interlaced --verbose run changelog:validate",
"create-package": "ts-node scripts/create-package",
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn constraints && yarn lint:dependencies",
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn constraints && yarn lint:dependencies && yarn lint:teams",
"lint:dependencies": "depcheck && yarn dedupe --check",
"lint:dependencies:fix": "depcheck && yarn dedupe",
"lint:eslint": "eslint . --cache --ext js,cjs,mjs,ts",
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write && yarn constraints --fix && yarn lint:dependencies:fix",
"lint:misc": "prettier '**/*.json' '**/*.md' '!**/CHANGELOG.old.md' '**/*.yml' '!.yarnrc.yml' '!merged-packages/**' --ignore-path .gitignore",
"lint:teams": "ts-node scripts/lint-teams-json.ts",
"prepack": "./scripts/prepack.sh",
"prepare-preview-builds": "./scripts/prepare-preview-builds.sh",
"publish-previews": "yarn workspaces foreach --all --no-private --parallel --verbose run publish:preview",
Expand Down Expand Up @@ -58,16 +59,19 @@
"@metamask/eslint-config-nodejs": "^12.1.0",
"@metamask/eslint-config-typescript": "^12.1.0",
"@metamask/eth-block-tracker": "^11.0.3",
"@metamask/eth-json-rpc-provider": "^4.1.6",
"@metamask/json-rpc-engine": "^10.0.1",
"@metamask/utils": "^10.0.0",
"@metamask/eth-json-rpc-provider": "^4.1.7",
"@metamask/json-rpc-engine": "^10.0.2",
"@metamask/utils": "^11.0.1",
"@ts-bridge/cli": "^0.6.1",
"@types/jest": "^27.4.1",
"@types/lodash": "^4.14.191",
"@types/node": "^16.18.54",
"@types/semver": "^7",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"@yarnpkg/cli": "^4.5.3",
"@yarnpkg/core": "^4.1.6",
"@yarnpkg/fslib": "^3.1.1",
"@yarnpkg/types": "^4.0.0",
"babel-jest": "^27.5.1",
"depcheck": "^1.4.7",
Expand Down
4 changes: 4 additions & 0 deletions packages/accounts-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Bump `@metamask/base-controller` from `^7.0.0` to `^7.1.0` ([#5079](https://github.com/MetaMask/core/pull/5079))

## [20.0.2]

### Changed
Expand Down
4 changes: 2 additions & 2 deletions packages/accounts-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@
},
"dependencies": {
"@ethereumjs/util": "^8.1.0",
"@metamask/base-controller": "^7.0.2",
"@metamask/base-controller": "^7.1.0",
"@metamask/eth-snap-keyring": "^7.0.0",
"@metamask/keyring-api": "^12.0.0",
"@metamask/keyring-internal-api": "^1.0.0",
"@metamask/snaps-sdk": "^6.7.0",
"@metamask/snaps-utils": "^8.3.0",
"@metamask/utils": "^10.0.0",
"@metamask/utils": "^11.0.1",
"deepmerge": "^4.2.2",
"ethereum-cryptography": "^2.1.2",
"immer": "^9.0.6",
Expand Down
4 changes: 4 additions & 0 deletions packages/address-book-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Bump `@metamask/base-controller` from `^7.0.0` to `^7.1.0` ([#5079](https://github.com/MetaMask/core/pull/5079))

## [6.0.2]

### Changed
Expand Down
4 changes: 2 additions & 2 deletions packages/address-book-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
},
"dependencies": {
"@metamask/base-controller": "^7.0.2",
"@metamask/base-controller": "^7.1.0",
"@metamask/controller-utils": "^11.4.4",
"@metamask/utils": "^10.0.0"
"@metamask/utils": "^11.0.1"
},
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
Expand Down
4 changes: 4 additions & 0 deletions packages/announcement-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Bump `@metamask/base-controller` from `^7.0.0` to `^7.1.0` ([#5079](https://github.com/MetaMask/core/pull/5079))

## [7.0.2]

### Changed
Expand Down
2 changes: 1 addition & 1 deletion packages/announcement-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
},
"dependencies": {
"@metamask/base-controller": "^7.0.2"
"@metamask/base-controller": "^7.1.0"
},
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
Expand Down
4 changes: 4 additions & 0 deletions packages/approval-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Bump `@metamask/base-controller` from `^7.0.0` to `^7.1.0` ([#5079](https://github.com/MetaMask/core/pull/5079))

## [7.1.1]

### Changed
Expand Down
8 changes: 4 additions & 4 deletions packages/approval-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
},
"dependencies": {
"@metamask/base-controller": "^7.0.2",
"@metamask/rpc-errors": "^7.0.1",
"@metamask/utils": "^10.0.0",
"nanoid": "^3.1.31"
"@metamask/base-controller": "^7.1.0",
"@metamask/rpc-errors": "^7.0.2",
"@metamask/utils": "^11.0.1",
"nanoid": "^3.3.8"
},
"devDependencies": {
"@metamask/auto-changelog": "^3.4.4",
Expand Down
4 changes: 4 additions & 0 deletions packages/assets-controllers/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Bump `@metamask/base-controller` from `^7.0.0` to `^7.1.0` ([#5079](https://github.com/MetaMask/core/pull/5079))

## [45.1.2]

### Changed
Expand Down
6 changes: 3 additions & 3 deletions packages/assets-controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@
"@ethersproject/contracts": "^5.7.0",
"@ethersproject/providers": "^5.7.0",
"@metamask/abi-utils": "^2.0.3",
"@metamask/base-controller": "^7.0.2",
"@metamask/base-controller": "^7.1.0",
"@metamask/contract-metadata": "^2.4.0",
"@metamask/controller-utils": "^11.4.4",
"@metamask/eth-query": "^4.0.0",
"@metamask/metamask-eth-abis": "^3.1.1",
"@metamask/polling-controller": "^12.0.2",
"@metamask/rpc-errors": "^7.0.1",
"@metamask/utils": "^10.0.0",
"@metamask/rpc-errors": "^7.0.2",
"@metamask/utils": "^11.0.1",
"@types/bn.js": "^5.1.5",
"@types/uuid": "^8.3.0",
"async-mutex": "^0.5.0",
Expand Down
104 changes: 102 additions & 2 deletions packages/assets-controllers/src/TokensController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ describe('TokensController', () => {
decimals: 6,
});
controller.ignoreTokens(['0x03'], InfuraNetworkType.goerli);
expect(controller.state.ignoredTokens).toStrictEqual(['0x03']);
expect(controller.state.ignoredTokens).toStrictEqual([]);

// Validate the overall ignored tokens state
expect(controller.state.allIgnoredTokens).toStrictEqual({
Expand All @@ -845,6 +845,106 @@ describe('TokensController', () => {
);
});

it('should not update detectedTokens, tokens, and ignoredTokens state given a network that is different from the globally selected network', async () => {
const selectedAddress = '0x0001';
const selectedAccount = createMockInternalAccount({
address: selectedAddress,
});

await withController(
{
mocks: {
getSelectedAccount: selectedAccount,
getAccount: selectedAccount,
},
},
async ({ controller, triggerSelectedAccountChange, changeNetwork }) => {
// Select the first account
triggerSelectedAccountChange(selectedAccount);

// Add tokens to sepolia
changeNetwork({ selectedNetworkClientId: InfuraNetworkType.sepolia });
await controller.addToken({
address: '0x01',
symbol: 'Token1',
decimals: 18,
});
expect(controller.state.tokens).toHaveLength(1);
expect(controller.state.ignoredTokens).toHaveLength(0);

// switch to goerli
changeNetwork({ selectedNetworkClientId: InfuraNetworkType.goerli });

// Add tokens to goerli
await controller.addToken({
address: '0x02',
symbol: 'Token2',
decimals: 8,
});

expect(controller.state.tokens).toHaveLength(1);
expect(controller.state.ignoredTokens).toHaveLength(0);

// ignore token on sepolia
controller.ignoreTokens(['0x01'], InfuraNetworkType.sepolia);

// as we are not on sepolia, tokens, ignoredTokens, and detectedTokens should not be affected
expect(controller.state.tokens).toHaveLength(1);
expect(controller.state.ignoredTokens).toHaveLength(0);
expect(controller.state.detectedTokens).toHaveLength(0);
},
);
});

it('should update tokens, and ignoredTokens and detectedTokens state for the globally selected network', async () => {
const selectedAddress = '0x0001';
const selectedAccount = createMockInternalAccount({
address: selectedAddress,
});

await withController(
{
mocks: {
getSelectedAccount: selectedAccount,
getAccount: selectedAccount,
},
},
async ({ controller, triggerSelectedAccountChange, changeNetwork }) => {
// Select the first account
triggerSelectedAccountChange(selectedAccount);

// Set globally selected network to sepolia
changeNetwork({ selectedNetworkClientId: InfuraNetworkType.sepolia });

// Add a token to sepolia
await controller.addToken({
address: '0x01',
symbol: 'Token1',
decimals: 18,
});
// Add a detected token to sepolia
await controller.addDetectedTokens([
{
address: '0x03',
symbol: 'Token3',
decimals: 18,
},
]);

expect(controller.state.tokens).toHaveLength(1);
expect(controller.state.ignoredTokens).toHaveLength(0);

// Ignore the token on sepolia
controller.ignoreTokens(['0x01'], InfuraNetworkType.sepolia);

// Ensure the tokens and ignoredTokens are updated for sepolia (globally selected network)
expect(controller.state.tokens).toHaveLength(0);
expect(controller.state.ignoredTokens).toHaveLength(1);
expect(controller.state.detectedTokens).toHaveLength(1);
},
);
});

it('should not retain ignored tokens from a different network', async () => {
const selectedAddress = '0x0001';
const selectedAccount = createMockInternalAccount({
Expand Down Expand Up @@ -879,7 +979,7 @@ describe('TokensController', () => {
// Ignore the token on Sepolia
controller.ignoreTokens(['0x01'], InfuraNetworkType.sepolia);
expect(controller.state.tokens).toHaveLength(0);
expect(controller.state.ignoredTokens).toStrictEqual(['0x01']);
expect(controller.state.ignoredTokens).toStrictEqual([]);

// Attempt to ignore a token that was added on Goerli
await controller.addToken({
Expand Down
10 changes: 6 additions & 4 deletions packages/assets-controllers/src/TokensController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ export class TokensController extends BaseController<
tokenAddressesToIgnore: string[],
networkClientId?: NetworkClientId,
) {
let interactingChainId;
let interactingChainId = this.#chainId;
if (networkClientId) {
interactingChainId = this.messagingSystem.call(
'NetworkController:getNetworkClientById',
Expand Down Expand Up @@ -624,12 +624,14 @@ export class TokensController extends BaseController<
});

this.update((state) => {
state.ignoredTokens = newIgnoredTokens;
state.tokens = newTokens;
state.detectedTokens = newDetectedTokens;
state.allIgnoredTokens = newAllIgnoredTokens;
state.allDetectedTokens = newAllDetectedTokens;
state.allTokens = newAllTokens;
if (interactingChainId === this.#chainId) {
state.detectedTokens = newDetectedTokens;
state.tokens = newTokens;
state.ignoredTokens = newIgnoredTokens;
}
});
}

Expand Down
Loading

0 comments on commit 925e9fd

Please sign in to comment.