Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
lavish0000 authored Feb 9, 2025
2 parents c4f66ba + 5b8c780 commit f23f57d
Show file tree
Hide file tree
Showing 256 changed files with 2,670 additions and 3,124 deletions.
4 changes: 4 additions & 0 deletions app/scripts/constants/sentry-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ export const SENTRY_BACKGROUND_STATE = {
MultichainBalancesController: {
balances: false,
},
MultichainAssetsController: {
accountsAssets: false,
assetsMetadata: false,
},
BridgeController: {
bridgeState: {
bridgeFeatureFlags: {
Expand Down
24 changes: 24 additions & 0 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
fetchMultiExchangeRate,
TokenBalancesController,
MultichainBalancesController,
MultichainAssetsController,
} from '@metamask/assets-controllers';
import { JsonRpcEngine } from '@metamask/json-rpc-engine';
import { createEngineStream } from '@metamask/json-rpc-middleware-stream';
Expand Down Expand Up @@ -785,6 +786,27 @@ export default class MetamaskController extends EventEmitter {
disabled: !this.preferencesController.state.useNftDetection,
});

const multichainAssetsControllerMessenger =
this.controllerMessenger.getRestricted({
name: 'MultichainAssetsController',
allowedEvents: [
'AccountsController:accountAdded',
'AccountsController:accountRemoved',
'AccountsController:accountAssetListUpdated',
],
allowedActions: [
'SnapController:handleRequest',
'SnapController:getAll',
'PermissionController:getPermissions',
'AccountsController:listMultichainAccounts',
],
});

this.multichainAssetsController = new MultichainAssetsController({
state: initState.MultichainAssetsController,
messenger: multichainAssetsControllerMessenger,
});

const metaMetricsControllerMessenger =
this.controllerMessenger.getRestricted({
name: 'MetaMetricsController',
Expand Down Expand Up @@ -2271,6 +2293,7 @@ export default class MetamaskController extends EventEmitter {
AppStateController: this.appStateController,
AppMetadataController: this.appMetadataController,
MultichainBalancesController: this.multichainBalancesController,
MultichainAssetsController: this.multichainAssetsController,
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
MultichainTransactionsController: this.multichainTransactionsController,
///: END:ONLY_INCLUDE_IF
Expand Down Expand Up @@ -2324,6 +2347,7 @@ export default class MetamaskController extends EventEmitter {
AppStateController: this.appStateController,
AppMetadataController: this.appMetadataController,
MultichainBalancesController: this.multichainBalancesController,
MultichainAssetsController: this.multichainAssetsController,
///: BEGIN:ONLY_INCLUDE_IF(build-flask)
MultichainTransactionsController: this.multichainTransactionsController,
///: END:ONLY_INCLUDE_IF
Expand Down
8 changes: 0 additions & 8 deletions development/circular-deps.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@
"ui/components/app/assets/asset-list/native-token/native-token.tsx",
"ui/components/app/assets/asset-list/native-token/use-native-token-balance.ts"
],
[
"ui/components/app/assets/token-list/token-list.tsx",
"ui/components/app/assets/util/calculateTokenBalance.ts"
],
[
"ui/components/app/assets/token-list/token-list.tsx",
"ui/components/app/assets/util/calculateTokenFiatAmount.ts"
],
[
"ui/components/app/name/name-details/name-details.tsx",
"ui/components/app/name/name.tsx"
Expand Down
5 changes: 2 additions & 3 deletions test/e2e/accounts/snap-account-eth-swap.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { withFixtures, defaultGanacheOptions, WINDOW_TITLES } from '../helpers';
import { withFixtures, WINDOW_TITLES } from '../helpers';
import { Driver } from '../webdriver/driver';
import FixtureBuilder from '../fixture-builder';
import { Ganache } from '../seeder/ganache';
import {
buildQuote,
reviewQuote,
Expand All @@ -12,6 +11,7 @@ import { TRADES_API_MOCK_RESULT } from '../../data/mock-data';
import { installSnapSimpleKeyring } from '../page-objects/flows/snap-simple-keyring.flow';
import { loginWithBalanceValidation } from '../page-objects/flows/login.flow';
import { Mockttp } from '../mock-e2e';
import { Ganache } from '../seeder/ganache';

const DAI = 'DAI';
const TEST_ETH = 'TESTETH';
Expand All @@ -32,7 +32,6 @@ describe('Snap Account - Swap', function () {
await withFixtures(
{
fixtures: new FixtureBuilder().build(),
ganacheOptions: defaultGanacheOptions,
title: this.test?.fullTitle(),
testSpecificMock: mockSwapsTransactionQuote,
},
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/flask/solana/common-solana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import HeaderNavbar from '../../page-objects/pages/header-navbar';
import AccountListPage from '../../page-objects/pages/account-list-page';
import FixtureBuilder from '../../fixture-builder';
import { ACCOUNT_TYPE } from '../../constants';
import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow';
import { loginWithoutBalanceValidation } from '../../page-objects/flows/login.flow';

const SOLANA_URL_REGEX =
/^https:\/\/(solana-mainnet\.infura\.io|api\.devnet\.solana\.com)/u;
Expand Down Expand Up @@ -497,7 +497,7 @@ export async function withSolanaAccountSnap(
],
},
async ({ driver, mockServer }: { driver: Driver; mockServer: Mockttp }) => {
await loginWithBalanceValidation(driver);
await loginWithoutBalanceValidation(driver);
const headerComponen = new HeaderNavbar(driver);
await headerComponen.openAccountMenu();
const accountListPage = new AccountListPage(driver);
Expand Down
4 changes: 3 additions & 1 deletion test/e2e/flask/user-operations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,10 @@ async function withAccountSnap(
useBundler: true,
usePaymaster: Boolean(paymaster),
dapp: true,
ganacheOptions: {
localNodeOptions: {
hardfork: 'london',
mnemonic:
'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent',
},
testSpecificMock: mockSwapsTransactionQuote,
},
Expand Down
14 changes: 8 additions & 6 deletions test/e2e/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async function withFixtures(options, testSuite) {
const {
dapp,
fixtures,
ganacheOptions,
localNodeOptions,
smartContract,
driverOptions,
dappOptions,
Expand Down Expand Up @@ -102,7 +102,7 @@ async function withFixtures(options, testSuite) {
let failed = false;
try {
if (!disableGanache) {
await ganacheServer.start(ganacheOptions);
await ganacheServer.start(localNodeOptions);
}
let contractRegistry;

Expand All @@ -121,8 +121,8 @@ async function withFixtures(options, testSuite) {
await fixtureServer.start();
fixtureServer.loadJsonState(fixtures, contractRegistry);

if (ganacheOptions?.concurrent) {
ganacheOptions.concurrent.forEach(async (ganacheSettings) => {
if (localNodeOptions?.concurrent) {
localNodeOptions.concurrent.forEach(async (ganacheSettings) => {
const { port, chainId, ganacheOptions2 } = ganacheSettings;
const server = new Ganache();
secondaryGanacheServer.push(server);
Expand All @@ -131,6 +131,8 @@ async function withFixtures(options, testSuite) {
chain: { chainId },
port,
vmErrorsOnRPCResponse: false,
mnemonic:
'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent',
...ganacheOptions2,
});
});
Expand Down Expand Up @@ -174,7 +176,7 @@ async function withFixtures(options, testSuite) {
mockServer,
testSpecificMock,
{
chainId: ganacheOptions?.chainId || 1337,
chainId: localNodeOptions?.chainId || 1337,
ethConversionInUsd,
},
);
Expand Down Expand Up @@ -308,7 +310,7 @@ async function withFixtures(options, testSuite) {
await ganacheServer.quit();
}

if (ganacheOptions?.concurrent) {
if (localNodeOptions?.concurrent) {
secondaryGanacheServer.forEach(async (server) => {
await server.quit();
});
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/json-rpc/eth_accounts.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { defaultGanacheOptions, withFixtures } from '../helpers';
import { withFixtures } from '../helpers';
import { Driver } from '../webdriver/driver';
import { Ganache } from '../seeder/ganache';
import FixtureBuilder from '../fixture-builder';
Expand All @@ -16,7 +16,6 @@ describe('eth_accounts', function () {
.withAccountsControllerAdditionalAccountIdentities()
.withPermissionControllerConnectedToTestDappWithTwoAccounts()
.build(),
ganacheOptions: defaultGanacheOptions,
title: this.test?.fullTitle(),
},
async ({
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/json-rpc/eth_call.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { strict as assert } from 'assert';
import { keccak } from 'ethereumjs-util';
import { defaultGanacheOptions, withFixtures } from '../helpers';
import { withFixtures } from '../helpers';
import { Driver } from '../webdriver/driver';
import FixtureBuilder from '../fixture-builder';
import { Ganache } from '../seeder/ganache';
Expand All @@ -17,7 +17,6 @@ describe('eth_call', function () {
fixtures: new FixtureBuilder()
.withPermissionControllerConnectedToTestDapp()
.build(),
ganacheOptions: defaultGanacheOptions,
smartContract,
title: this.test?.fullTitle(),
},
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/json-rpc/eth_chainId.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { defaultGanacheOptions, withFixtures } from '../helpers';
import { withFixtures } from '../helpers';
import FixtureBuilder from '../fixture-builder';
import { Driver } from '../webdriver/driver';
import { Ganache } from '../seeder/ganache';
Expand All @@ -13,7 +13,6 @@ describe('eth_chainId', function () {
fixtures: new FixtureBuilder()
.withPermissionControllerConnectedToTestDapp()
.build(),
ganacheOptions: defaultGanacheOptions,
title: this.test?.fullTitle(),
},
async ({
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/json-rpc/eth_coinbase.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { defaultGanacheOptions, withFixtures } from '../helpers';
import { withFixtures } from '../helpers';
import { loginWithBalanceValidation } from '../page-objects/flows/login.flow';
import FixtureBuilder from '../fixture-builder';
import { Driver } from '../webdriver/driver';
Expand All @@ -13,7 +13,6 @@ describe('eth_coinbase', function () {
fixtures: new FixtureBuilder()
.withPermissionControllerConnectedToTestDapp()
.build(),
ganacheOptions: defaultGanacheOptions,
title: this.test?.fullTitle(),
},
async ({
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/json-rpc/eth_estimateGas.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { defaultGanacheOptions, withFixtures } from '../helpers';
import { withFixtures } from '../helpers';
import { loginWithBalanceValidation } from '../page-objects/flows/login.flow';
import FixtureBuilder from '../fixture-builder';
import { Driver } from '../webdriver/driver';
Expand All @@ -13,7 +13,6 @@ describe('eth_estimateGas', function () {
fixtures: new FixtureBuilder()
.withPermissionControllerConnectedToTestDapp()
.build(),
ganacheOptions: defaultGanacheOptions,
title: this.test?.fullTitle(),
},
async ({
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/json-rpc/eth_gasPrice.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { defaultGanacheOptions, withFixtures } from '../helpers';
import { withFixtures } from '../helpers';
import { loginWithBalanceValidation } from '../page-objects/flows/login.flow';
import FixtureBuilder from '../fixture-builder';
import { Driver } from '../webdriver/driver';
Expand All @@ -13,7 +13,6 @@ describe('eth_gasPrice', function () {
fixtures: new FixtureBuilder()
.withPermissionControllerConnectedToTestDapp()
.build(),
ganacheOptions: defaultGanacheOptions,
title: this.test?.fullTitle(),
},
async ({
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/json-rpc/eth_newBlockFilter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('eth_newBlockFilter', function () {
fixtures: new FixtureBuilder()
.withPermissionControllerConnectedToTestDapp()
.build(),
ganacheOptions,
localNodeOptions: ganacheOptions,
title: this.test?.fullTitle(),
},
async ({
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/json-rpc/eth_requestAccounts.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { defaultGanacheOptions, withFixtures } from '../helpers';
import { withFixtures } from '../helpers';
import { loginWithBalanceValidation } from '../page-objects/flows/login.flow';
import FixtureBuilder from '../fixture-builder';
import { Driver } from '../webdriver/driver';
Expand All @@ -13,7 +13,6 @@ describe('eth_requestAccounts', function () {
fixtures: new FixtureBuilder()
.withPermissionControllerConnectedToTestDapp()
.build(),
ganacheOptions: defaultGanacheOptions,
title: this.test?.fullTitle(),
},
async ({
Expand Down
12 changes: 10 additions & 2 deletions test/e2e/json-rpc/eth_sendTransaction.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ describe('eth_sendTransaction', function () {
fixtures: new FixtureBuilder()
.withPermissionControllerConnectedToTestDapp()
.build(),
ganacheOptions: generateGanacheOptions({ hardfork: 'london' }),
localNodeOptions: generateGanacheOptions({
hardfork: 'london',
mnemonic:
'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent',
}),
title: this.test.fullTitle(),
},
async ({ driver }) => {
Expand Down Expand Up @@ -64,7 +68,11 @@ describe('eth_sendTransaction', function () {
fixtures: new FixtureBuilder()
.withPermissionControllerConnectedToTestDapp()
.build(),
ganacheOptions: generateGanacheOptions({ hardfork: 'london' }),
localNodeOptions: generateGanacheOptions({
hardfork: 'london',
mnemonic:
'phrase upgrade clock rough situate wedding elder clever doctor stamp excess tent',
}),
title: this.test.fullTitle(),
},
async ({ driver }) => {
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/json-rpc/eth_subscribe.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { strict as assert } from 'assert';
import { defaultGanacheOptions, withFixtures } from '../helpers';
import { withFixtures } from '../helpers';
import { loginWithBalanceValidation } from '../page-objects/flows/login.flow';
import FixtureBuilder from '../fixture-builder';
import { Driver } from '../webdriver/driver';
Expand All @@ -13,7 +13,6 @@ describe('eth_subscribe', function () {
fixtures: new FixtureBuilder()
.withPermissionControllerConnectedToTestDapp()
.build(),
ganacheOptions: defaultGanacheOptions,
title: this.test?.fullTitle(),
},
async ({
Expand Down
8 changes: 4 additions & 4 deletions test/e2e/json-rpc/switchEthereumChain.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('Switch Ethereum Chain for two dapps', function () {
.build(),
dappOptions: { numberOfDapps: 2 },

ganacheOptions: {
localNodeOptions: {
...defaultGanacheOptions,
concurrent: [{ port: 8546, chainId: 1338 }],
},
Expand Down Expand Up @@ -86,7 +86,7 @@ describe('Switch Ethereum Chain for two dapps', function () {
.withPreferencesControllerSmartTransactionsOptedOut()
.build(),
dappOptions: { numberOfDapps: 2 },
ganacheOptions: {
localNodeOptions: {
...defaultGanacheOptions,
concurrent: [{ port: 8546, chainId: 1338 }],
},
Expand Down Expand Up @@ -196,7 +196,7 @@ describe('Switch Ethereum Chain for two dapps', function () {
.withNetworkControllerDoubleGanache()
.build(),
dappOptions: { numberOfDapps: 2 },
ganacheOptions: {
localNodeOptions: {
...defaultGanacheOptions,
concurrent: [{ port: 8546, chainId: 1338 }],
},
Expand Down Expand Up @@ -304,7 +304,7 @@ describe('Switch Ethereum Chain for two dapps', function () {
.withNetworkControllerDoubleGanache()
.build(),
dappOptions: { numberOfDapps: 2 },
ganacheOptions: {
localNodeOptions: {
...defaultGanacheOptions,
concurrent: [{ port: 8546, chainId: 1338 }],
},
Expand Down
Loading

0 comments on commit f23f57d

Please sign in to comment.