diff --git a/.circleci/config.yml b/.circleci/config.yml index 3e3ccba9005e..3178a687a617 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,13 +3,13 @@ version: 2.1 executors: node-browsers-small: docker: - - image: cimg/node:20.17-browsers + - image: cimg/node:20.18-browsers resource_class: small environment: NODE_OPTIONS: --max_old_space_size=2048 node-browsers-medium: docker: - - image: cimg/node:20.17-browsers + - image: cimg/node:20.18-browsers resource_class: medium environment: NODE_OPTIONS: --max_old_space_size=3072 @@ -21,7 +21,7 @@ executors: NODE_OPTIONS: --max_old_space_size=6144 node-browsers-medium-plus: docker: - - image: cimg/node:20.17-browsers + - image: cimg/node:20.18-browsers resource_class: medium+ environment: NODE_OPTIONS: --max_old_space_size=4096 diff --git a/.nvmrc b/.nvmrc index 8cfab175cf90..bd67975ba627 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -v20.17 +v20.18 diff --git a/app/scripts/controllers/metametrics-controller.test.ts b/app/scripts/controllers/metametrics-controller.test.ts index 58fad403fdab..99ed4d2e2e48 100644 --- a/app/scripts/controllers/metametrics-controller.test.ts +++ b/app/scripts/controllers/metametrics-controller.test.ts @@ -1453,7 +1453,7 @@ describe('MetaMetricsController', function () { participateInMetaMetrics: true, currentCurrency: 'usd', dataCollectionForMarketing: false, - preferences: { privacyMode: true }, + preferences: { privacyMode: true, tokenNetworkFilter: [] }, ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) custodyAccountDetails: {}, ///: END:ONLY_INCLUDE_IF @@ -1494,6 +1494,7 @@ describe('MetaMetricsController', function () { ///: END:ONLY_INCLUDE_IF [MetaMetricsUserTrait.TokenSortPreference]: 'token-sort-key', [MetaMetricsUserTrait.PrivacyModeEnabled]: true, + [MetaMetricsUserTrait.NetworkFilterPreference]: [], }); }); }); @@ -1543,7 +1544,7 @@ describe('MetaMetricsController', function () { allNfts: {}, participateInMetaMetrics: true, dataCollectionForMarketing: false, - preferences: { privacyMode: true }, + preferences: { privacyMode: true, tokenNetworkFilter: [] }, securityAlertsEnabled: true, names: { ethereumAddress: {}, @@ -1607,7 +1608,7 @@ describe('MetaMetricsController', function () { allNfts: {}, participateInMetaMetrics: true, dataCollectionForMarketing: false, - preferences: { privacyMode: true }, + preferences: { privacyMode: true, tokenNetworkFilter: [] }, securityAlertsEnabled: true, ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) custodyAccountDetails: {}, @@ -1672,7 +1673,7 @@ describe('MetaMetricsController', function () { }, participateInMetaMetrics: true, dataCollectionForMarketing: false, - preferences: { privacyMode: true }, + preferences: { privacyMode: true, tokenNetworkFilter: [] }, securityAlertsEnabled: true, security_providers: ['blockaid'], currentCurrency: 'usd', @@ -1718,7 +1719,7 @@ describe('MetaMetricsController', function () { allNfts: {}, participateInMetaMetrics: true, dataCollectionForMarketing: false, - preferences: { privacyMode: true }, + preferences: { privacyMode: true, tokenNetworkFilter: [] }, names: { ethereumAddress: {}, }, diff --git a/app/scripts/controllers/metametrics-controller.ts b/app/scripts/controllers/metametrics-controller.ts index d29a2840eb27..b2b78a4e6406 100644 --- a/app/scripts/controllers/metametrics-controller.ts +++ b/app/scripts/controllers/metametrics-controller.ts @@ -166,6 +166,7 @@ export type MetaMaskState = { currentCurrency: string; preferences: { privacyMode: PreferencesControllerState['preferences']['privacyMode']; + tokenNetworkFilter: string[]; }; ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) custodyAccountDetails: { @@ -1233,6 +1234,9 @@ export default class MetaMetricsController extends BaseController< metamaskState.tokenSortConfig?.key || '', [MetaMetricsUserTrait.PrivacyModeEnabled]: metamaskState.preferences.privacyMode, + [MetaMetricsUserTrait.NetworkFilterPreference]: Object.keys( + metamaskState.preferences.tokenNetworkFilter || {}, + ), }; if (!previousUserTraits) { diff --git a/app/scripts/controllers/permissions/caveat-mutators.js b/app/scripts/controllers/permissions/caveat-mutators.js index 551d1f7b37b2..047341e34770 100644 --- a/app/scripts/controllers/permissions/caveat-mutators.js +++ b/app/scripts/controllers/permissions/caveat-mutators.js @@ -33,14 +33,14 @@ function removeAccount(targetAccount, existingAccounts) { ); if (newAccounts.length === existingAccounts.length) { - return { operation: CaveatMutatorOperation.noop }; + return { operation: CaveatMutatorOperation.Noop }; } else if (newAccounts.length > 0) { return { - operation: CaveatMutatorOperation.updateValue, + operation: CaveatMutatorOperation.UpdateValue, value: newAccounts, }; } - return { operation: CaveatMutatorOperation.revokePermission }; + return { operation: CaveatMutatorOperation.RevokePermission }; } /** @@ -60,12 +60,12 @@ function removeChainId(targetChainId, existingChainIds) { ); if (newChainIds.length === existingChainIds.length) { - return { operation: CaveatMutatorOperation.noop }; + return { operation: CaveatMutatorOperation.Noop }; } else if (newChainIds.length > 0) { return { - operation: CaveatMutatorOperation.updateValue, + operation: CaveatMutatorOperation.UpdateValue, value: newChainIds, }; } - return { operation: CaveatMutatorOperation.revokePermission }; + return { operation: CaveatMutatorOperation.RevokePermission }; } diff --git a/app/scripts/controllers/permissions/caveat-mutators.test.js b/app/scripts/controllers/permissions/caveat-mutators.test.js index a87115dc744b..8c16924514f4 100644 --- a/app/scripts/controllers/permissions/caveat-mutators.test.js +++ b/app/scripts/controllers/permissions/caveat-mutators.test.js @@ -14,20 +14,20 @@ describe('caveat mutators', () => { describe('removeAccount', () => { it('returns the no-op operation if the target account is not permitted', () => { expect(removeAccount(address2, [address1])).toStrictEqual({ - operation: CaveatMutatorOperation.noop, + operation: CaveatMutatorOperation.Noop, }); }); it('returns the update operation and a new value if the target account is permitted', () => { expect(removeAccount(address2, [address1, address2])).toStrictEqual({ - operation: CaveatMutatorOperation.updateValue, + operation: CaveatMutatorOperation.UpdateValue, value: [address1], }); }); it('returns the revoke permission operation the target account is the only permitted account', () => { expect(removeAccount(address1, [address1])).toStrictEqual({ - operation: CaveatMutatorOperation.revokePermission, + operation: CaveatMutatorOperation.RevokePermission, }); }); @@ -36,20 +36,20 @@ describe('caveat mutators', () => { const checksummedAddress3 = '0x95222290dd7278AA3DDd389cc1E1d165Cc4BaeE5'; expect(removeAccount(checksummedAddress3, [address3])).toStrictEqual({ - operation: CaveatMutatorOperation.revokePermission, + operation: CaveatMutatorOperation.RevokePermission, }); }); describe('Multichain behaviour', () => { it('returns the no-op operation if the target account is not permitted', () => { expect(removeAccount(address2, [nonEvmAddress])).toStrictEqual({ - operation: CaveatMutatorOperation.noop, + operation: CaveatMutatorOperation.Noop, }); }); it('can revoke permission for non-EVM addresses', () => { expect(removeAccount(nonEvmAddress, [nonEvmAddress])).toStrictEqual({ - operation: CaveatMutatorOperation.revokePermission, + operation: CaveatMutatorOperation.RevokePermission, }); }); @@ -57,7 +57,7 @@ describe('caveat mutators', () => { expect( removeAccount(nonEvmAddress, [address1, nonEvmAddress]), ).toStrictEqual({ - operation: CaveatMutatorOperation.updateValue, + operation: CaveatMutatorOperation.UpdateValue, value: [address1], }); }); diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 55888558c6d6..39e34955cac2 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -4146,8 +4146,7 @@ export default class MetamaskController extends EventEmitter { ), // GasFeeController - gasFeeStartPollingByNetworkClientId: - gasFeeController.startPollingByNetworkClientId.bind(gasFeeController), + gasFeeStartPolling: gasFeeController.startPolling.bind(gasFeeController), gasFeeStopPollingByPollingToken: gasFeeController.stopPollingByPollingToken.bind(gasFeeController), diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json index 30456a0bd61d..cf72074493e6 100644 --- a/lavamoat/browserify/beta/policy.json +++ b/lavamoat/browserify/beta/policy.json @@ -1439,14 +1439,6 @@ "uuid": true } }, - "@metamask/gas-fee-controller>@metamask/base-controller": { - "globals": { - "setTimeout": true - }, - "packages": { - "immer": true - } - }, "@metamask/gas-fee-controller>@metamask/polling-controller": { "globals": { "clearTimeout": true, @@ -1454,7 +1446,7 @@ "setTimeout": true }, "packages": { - "@metamask/gas-fee-controller>@metamask/base-controller": true, + "@metamask/base-controller": true, "@metamask/snaps-utils>fast-json-stable-stringify": true, "uuid": true } @@ -2173,82 +2165,16 @@ "console.error": true }, "packages": { + "@metamask/base-controller": true, "@metamask/controller-utils": true, - "@metamask/permission-controller>@metamask/base-controller": true, - "@metamask/permission-controller>@metamask/json-rpc-engine": true, - "@metamask/permission-controller>@metamask/rpc-errors": true, - "@metamask/permission-controller>@metamask/utils": true, + "@metamask/json-rpc-engine": true, "@metamask/permission-controller>nanoid": true, + "@metamask/rpc-errors": true, + "@metamask/utils": true, "deep-freeze-strict": true, "immer": true } }, - "@metamask/permission-controller>@metamask/base-controller": { - "globals": { - "setTimeout": true - }, - "packages": { - "immer": true - } - }, - "@metamask/permission-controller>@metamask/json-rpc-engine": { - "packages": { - "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/utils": true, - "@metamask/permission-controller>@metamask/rpc-errors": true, - "@metamask/safe-event-emitter": true - } - }, - "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>@metamask/superstruct": true, - "@metamask/utils>@scure/base": true, - "@metamask/utils>pony-cause": true, - "@noble/hashes": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, - "@metamask/permission-controller>@metamask/rpc-errors": { - "packages": { - "@metamask/permission-controller>@metamask/rpc-errors>@metamask/utils": true, - "@metamask/rpc-errors>fast-safe-stringify": true - } - }, - "@metamask/permission-controller>@metamask/rpc-errors>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>@metamask/superstruct": true, - "@metamask/utils>@scure/base": true, - "@metamask/utils>pony-cause": true, - "@noble/hashes": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, - "@metamask/permission-controller>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>@metamask/superstruct": true, - "@metamask/utils>@scure/base": true, - "@metamask/utils>pony-cause": true, - "@noble/hashes": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, "@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -2703,13 +2629,13 @@ "@ethersproject/providers": true, "@metamask/controller-utils": true, "@metamask/eth-query": true, - "@metamask/gas-fee-controller": true, "@metamask/metamask-eth-abis": true, "@metamask/name-controller>async-mutex": true, "@metamask/network-controller": true, "@metamask/smart-transactions-controller>@metamask/base-controller": true, "@metamask/smart-transactions-controller>@metamask/transaction-controller>@ethereumjs/tx": true, "@metamask/smart-transactions-controller>@metamask/transaction-controller>@ethereumjs/util": true, + "@metamask/smart-transactions-controller>@metamask/transaction-controller>@metamask/gas-fee-controller": true, "@metamask/smart-transactions-controller>@metamask/transaction-controller>@metamask/nonce-tracker": true, "@metamask/smart-transactions-controller>@metamask/transaction-controller>@metamask/rpc-errors": true, "@metamask/smart-transactions-controller>@metamask/transaction-controller>@metamask/utils": true, @@ -2750,6 +2676,20 @@ "webpack>events": true } }, + "@metamask/smart-transactions-controller>@metamask/transaction-controller>@metamask/gas-fee-controller": { + "globals": { + "clearInterval": true, + "console.error": true, + "setInterval": true + }, + "packages": { + "@metamask/controller-utils": true, + "@metamask/eth-query": true, + "@metamask/smart-transactions-controller>@metamask/polling-controller": true, + "bn.js": true, + "uuid": true + } + }, "@metamask/smart-transactions-controller>@metamask/transaction-controller>@metamask/nonce-tracker": { "packages": { "@ethersproject/providers": true, @@ -2822,9 +2762,9 @@ "@metamask/json-rpc-engine": true, "@metamask/json-rpc-middleware-stream": true, "@metamask/object-multiplex": true, + "@metamask/permission-controller": true, "@metamask/post-message-stream": true, "@metamask/rpc-errors": true, - "@metamask/snaps-controllers>@metamask/permission-controller": true, "@metamask/snaps-controllers>@xstate/fsm": true, "@metamask/snaps-controllers>concat-stream": true, "@metamask/snaps-controllers>get-npm-tarball-url": true, @@ -2848,21 +2788,6 @@ "crypto.getRandomValues": true } }, - "@metamask/snaps-controllers>@metamask/permission-controller": { - "globals": { - "console.error": true - }, - "packages": { - "@metamask/base-controller": true, - "@metamask/controller-utils": true, - "@metamask/json-rpc-engine": true, - "@metamask/rpc-errors": true, - "@metamask/snaps-controllers>nanoid": true, - "@metamask/utils": true, - "deep-freeze-strict": true, - "immer": true - } - }, "@metamask/snaps-controllers>concat-stream": { "packages": { "browserify>buffer": true, @@ -2920,8 +2845,8 @@ }, "@metamask/snaps-rpc-methods": { "packages": { + "@metamask/permission-controller": true, "@metamask/rpc-errors": true, - "@metamask/snaps-rpc-methods>@metamask/permission-controller": true, "@metamask/snaps-sdk": true, "@metamask/snaps-sdk>@metamask/key-tree": true, "@metamask/snaps-utils": true, @@ -2930,26 +2855,6 @@ "@noble/hashes": true } }, - "@metamask/snaps-rpc-methods>@metamask/permission-controller": { - "globals": { - "console.error": true - }, - "packages": { - "@metamask/base-controller": true, - "@metamask/controller-utils": true, - "@metamask/json-rpc-engine": true, - "@metamask/rpc-errors": true, - "@metamask/snaps-rpc-methods>@metamask/permission-controller>nanoid": true, - "@metamask/utils": true, - "deep-freeze-strict": true, - "immer": true - } - }, - "@metamask/snaps-rpc-methods>@metamask/permission-controller>nanoid": { - "globals": { - "crypto.getRandomValues": true - } - }, "@metamask/snaps-sdk": { "globals": { "fetch": true @@ -3000,10 +2905,10 @@ "fetch": true }, "packages": { + "@metamask/permission-controller": true, "@metamask/rpc-errors": true, "@metamask/snaps-sdk": true, "@metamask/snaps-sdk>@metamask/key-tree": true, - "@metamask/snaps-utils>@metamask/permission-controller": true, "@metamask/snaps-utils>@metamask/slip44": true, "@metamask/snaps-utils>cron-parser": true, "@metamask/snaps-utils>fast-json-stable-stringify": true, @@ -3019,26 +2924,6 @@ "semver": true } }, - "@metamask/snaps-utils>@metamask/permission-controller": { - "globals": { - "console.error": true - }, - "packages": { - "@metamask/base-controller": true, - "@metamask/controller-utils": true, - "@metamask/json-rpc-engine": true, - "@metamask/rpc-errors": true, - "@metamask/snaps-utils>@metamask/permission-controller>nanoid": true, - "@metamask/utils": true, - "deep-freeze-strict": true, - "immer": true - } - }, - "@metamask/snaps-utils>@metamask/permission-controller>nanoid": { - "globals": { - "crypto.getRandomValues": true - } - }, "@metamask/snaps-utils>@metamask/snaps-registry": { "packages": { "@metamask/message-signing-snap>@noble/curves": true, @@ -3144,29 +3029,21 @@ "fetch": true }, "packages": { + "@metamask/base-controller": true, "@metamask/controller-utils": true, "@metamask/eth-query": true, "@metamask/gas-fee-controller": true, + "@metamask/rpc-errors": true, "@metamask/transaction-controller": true, - "@metamask/user-operation-controller>@metamask/base-controller": true, "@metamask/user-operation-controller>@metamask/polling-controller": true, - "@metamask/user-operation-controller>@metamask/rpc-errors": true, "@metamask/user-operation-controller>@metamask/utils": true, + "@metamask/utils>@metamask/superstruct": true, "bn.js": true, "lodash": true, - "superstruct": true, "uuid": true, "webpack>events": true } }, - "@metamask/user-operation-controller>@metamask/base-controller": { - "globals": { - "setTimeout": true - }, - "packages": { - "immer": true - } - }, "@metamask/user-operation-controller>@metamask/polling-controller": { "globals": { "clearTimeout": true, @@ -3174,32 +3051,11 @@ "setTimeout": true }, "packages": { + "@metamask/base-controller": true, "@metamask/snaps-utils>fast-json-stable-stringify": true, - "@metamask/user-operation-controller>@metamask/base-controller": true, "uuid": true } }, - "@metamask/user-operation-controller>@metamask/rpc-errors": { - "packages": { - "@metamask/rpc-errors>fast-safe-stringify": true, - "@metamask/user-operation-controller>@metamask/rpc-errors>@metamask/utils": true - } - }, - "@metamask/user-operation-controller>@metamask/rpc-errors>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>@metamask/superstruct": true, - "@metamask/utils>@scure/base": true, - "@metamask/utils>pony-cause": true, - "@noble/hashes": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, "@metamask/user-operation-controller>@metamask/utils": { "globals": { "TextDecoder": true, @@ -5789,12 +5645,6 @@ "string.prototype.matchall>get-intrinsic": true } }, - "superstruct": { - "globals": { - "console.warn": true, - "define": true - } - }, "terser>source-map-support>buffer-from": { "packages": { "browserify>buffer": true diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json index 30456a0bd61d..cf72074493e6 100644 --- a/lavamoat/browserify/flask/policy.json +++ b/lavamoat/browserify/flask/policy.json @@ -1439,14 +1439,6 @@ "uuid": true } }, - "@metamask/gas-fee-controller>@metamask/base-controller": { - "globals": { - "setTimeout": true - }, - "packages": { - "immer": true - } - }, "@metamask/gas-fee-controller>@metamask/polling-controller": { "globals": { "clearTimeout": true, @@ -1454,7 +1446,7 @@ "setTimeout": true }, "packages": { - "@metamask/gas-fee-controller>@metamask/base-controller": true, + "@metamask/base-controller": true, "@metamask/snaps-utils>fast-json-stable-stringify": true, "uuid": true } @@ -2173,82 +2165,16 @@ "console.error": true }, "packages": { + "@metamask/base-controller": true, "@metamask/controller-utils": true, - "@metamask/permission-controller>@metamask/base-controller": true, - "@metamask/permission-controller>@metamask/json-rpc-engine": true, - "@metamask/permission-controller>@metamask/rpc-errors": true, - "@metamask/permission-controller>@metamask/utils": true, + "@metamask/json-rpc-engine": true, "@metamask/permission-controller>nanoid": true, + "@metamask/rpc-errors": true, + "@metamask/utils": true, "deep-freeze-strict": true, "immer": true } }, - "@metamask/permission-controller>@metamask/base-controller": { - "globals": { - "setTimeout": true - }, - "packages": { - "immer": true - } - }, - "@metamask/permission-controller>@metamask/json-rpc-engine": { - "packages": { - "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/utils": true, - "@metamask/permission-controller>@metamask/rpc-errors": true, - "@metamask/safe-event-emitter": true - } - }, - "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>@metamask/superstruct": true, - "@metamask/utils>@scure/base": true, - "@metamask/utils>pony-cause": true, - "@noble/hashes": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, - "@metamask/permission-controller>@metamask/rpc-errors": { - "packages": { - "@metamask/permission-controller>@metamask/rpc-errors>@metamask/utils": true, - "@metamask/rpc-errors>fast-safe-stringify": true - } - }, - "@metamask/permission-controller>@metamask/rpc-errors>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>@metamask/superstruct": true, - "@metamask/utils>@scure/base": true, - "@metamask/utils>pony-cause": true, - "@noble/hashes": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, - "@metamask/permission-controller>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>@metamask/superstruct": true, - "@metamask/utils>@scure/base": true, - "@metamask/utils>pony-cause": true, - "@noble/hashes": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, "@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -2703,13 +2629,13 @@ "@ethersproject/providers": true, "@metamask/controller-utils": true, "@metamask/eth-query": true, - "@metamask/gas-fee-controller": true, "@metamask/metamask-eth-abis": true, "@metamask/name-controller>async-mutex": true, "@metamask/network-controller": true, "@metamask/smart-transactions-controller>@metamask/base-controller": true, "@metamask/smart-transactions-controller>@metamask/transaction-controller>@ethereumjs/tx": true, "@metamask/smart-transactions-controller>@metamask/transaction-controller>@ethereumjs/util": true, + "@metamask/smart-transactions-controller>@metamask/transaction-controller>@metamask/gas-fee-controller": true, "@metamask/smart-transactions-controller>@metamask/transaction-controller>@metamask/nonce-tracker": true, "@metamask/smart-transactions-controller>@metamask/transaction-controller>@metamask/rpc-errors": true, "@metamask/smart-transactions-controller>@metamask/transaction-controller>@metamask/utils": true, @@ -2750,6 +2676,20 @@ "webpack>events": true } }, + "@metamask/smart-transactions-controller>@metamask/transaction-controller>@metamask/gas-fee-controller": { + "globals": { + "clearInterval": true, + "console.error": true, + "setInterval": true + }, + "packages": { + "@metamask/controller-utils": true, + "@metamask/eth-query": true, + "@metamask/smart-transactions-controller>@metamask/polling-controller": true, + "bn.js": true, + "uuid": true + } + }, "@metamask/smart-transactions-controller>@metamask/transaction-controller>@metamask/nonce-tracker": { "packages": { "@ethersproject/providers": true, @@ -2822,9 +2762,9 @@ "@metamask/json-rpc-engine": true, "@metamask/json-rpc-middleware-stream": true, "@metamask/object-multiplex": true, + "@metamask/permission-controller": true, "@metamask/post-message-stream": true, "@metamask/rpc-errors": true, - "@metamask/snaps-controllers>@metamask/permission-controller": true, "@metamask/snaps-controllers>@xstate/fsm": true, "@metamask/snaps-controllers>concat-stream": true, "@metamask/snaps-controllers>get-npm-tarball-url": true, @@ -2848,21 +2788,6 @@ "crypto.getRandomValues": true } }, - "@metamask/snaps-controllers>@metamask/permission-controller": { - "globals": { - "console.error": true - }, - "packages": { - "@metamask/base-controller": true, - "@metamask/controller-utils": true, - "@metamask/json-rpc-engine": true, - "@metamask/rpc-errors": true, - "@metamask/snaps-controllers>nanoid": true, - "@metamask/utils": true, - "deep-freeze-strict": true, - "immer": true - } - }, "@metamask/snaps-controllers>concat-stream": { "packages": { "browserify>buffer": true, @@ -2920,8 +2845,8 @@ }, "@metamask/snaps-rpc-methods": { "packages": { + "@metamask/permission-controller": true, "@metamask/rpc-errors": true, - "@metamask/snaps-rpc-methods>@metamask/permission-controller": true, "@metamask/snaps-sdk": true, "@metamask/snaps-sdk>@metamask/key-tree": true, "@metamask/snaps-utils": true, @@ -2930,26 +2855,6 @@ "@noble/hashes": true } }, - "@metamask/snaps-rpc-methods>@metamask/permission-controller": { - "globals": { - "console.error": true - }, - "packages": { - "@metamask/base-controller": true, - "@metamask/controller-utils": true, - "@metamask/json-rpc-engine": true, - "@metamask/rpc-errors": true, - "@metamask/snaps-rpc-methods>@metamask/permission-controller>nanoid": true, - "@metamask/utils": true, - "deep-freeze-strict": true, - "immer": true - } - }, - "@metamask/snaps-rpc-methods>@metamask/permission-controller>nanoid": { - "globals": { - "crypto.getRandomValues": true - } - }, "@metamask/snaps-sdk": { "globals": { "fetch": true @@ -3000,10 +2905,10 @@ "fetch": true }, "packages": { + "@metamask/permission-controller": true, "@metamask/rpc-errors": true, "@metamask/snaps-sdk": true, "@metamask/snaps-sdk>@metamask/key-tree": true, - "@metamask/snaps-utils>@metamask/permission-controller": true, "@metamask/snaps-utils>@metamask/slip44": true, "@metamask/snaps-utils>cron-parser": true, "@metamask/snaps-utils>fast-json-stable-stringify": true, @@ -3019,26 +2924,6 @@ "semver": true } }, - "@metamask/snaps-utils>@metamask/permission-controller": { - "globals": { - "console.error": true - }, - "packages": { - "@metamask/base-controller": true, - "@metamask/controller-utils": true, - "@metamask/json-rpc-engine": true, - "@metamask/rpc-errors": true, - "@metamask/snaps-utils>@metamask/permission-controller>nanoid": true, - "@metamask/utils": true, - "deep-freeze-strict": true, - "immer": true - } - }, - "@metamask/snaps-utils>@metamask/permission-controller>nanoid": { - "globals": { - "crypto.getRandomValues": true - } - }, "@metamask/snaps-utils>@metamask/snaps-registry": { "packages": { "@metamask/message-signing-snap>@noble/curves": true, @@ -3144,29 +3029,21 @@ "fetch": true }, "packages": { + "@metamask/base-controller": true, "@metamask/controller-utils": true, "@metamask/eth-query": true, "@metamask/gas-fee-controller": true, + "@metamask/rpc-errors": true, "@metamask/transaction-controller": true, - "@metamask/user-operation-controller>@metamask/base-controller": true, "@metamask/user-operation-controller>@metamask/polling-controller": true, - "@metamask/user-operation-controller>@metamask/rpc-errors": true, "@metamask/user-operation-controller>@metamask/utils": true, + "@metamask/utils>@metamask/superstruct": true, "bn.js": true, "lodash": true, - "superstruct": true, "uuid": true, "webpack>events": true } }, - "@metamask/user-operation-controller>@metamask/base-controller": { - "globals": { - "setTimeout": true - }, - "packages": { - "immer": true - } - }, "@metamask/user-operation-controller>@metamask/polling-controller": { "globals": { "clearTimeout": true, @@ -3174,32 +3051,11 @@ "setTimeout": true }, "packages": { + "@metamask/base-controller": true, "@metamask/snaps-utils>fast-json-stable-stringify": true, - "@metamask/user-operation-controller>@metamask/base-controller": true, "uuid": true } }, - "@metamask/user-operation-controller>@metamask/rpc-errors": { - "packages": { - "@metamask/rpc-errors>fast-safe-stringify": true, - "@metamask/user-operation-controller>@metamask/rpc-errors>@metamask/utils": true - } - }, - "@metamask/user-operation-controller>@metamask/rpc-errors>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>@metamask/superstruct": true, - "@metamask/utils>@scure/base": true, - "@metamask/utils>pony-cause": true, - "@noble/hashes": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, "@metamask/user-operation-controller>@metamask/utils": { "globals": { "TextDecoder": true, @@ -5789,12 +5645,6 @@ "string.prototype.matchall>get-intrinsic": true } }, - "superstruct": { - "globals": { - "console.warn": true, - "define": true - } - }, "terser>source-map-support>buffer-from": { "packages": { "browserify>buffer": true diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json index 30456a0bd61d..cf72074493e6 100644 --- a/lavamoat/browserify/main/policy.json +++ b/lavamoat/browserify/main/policy.json @@ -1439,14 +1439,6 @@ "uuid": true } }, - "@metamask/gas-fee-controller>@metamask/base-controller": { - "globals": { - "setTimeout": true - }, - "packages": { - "immer": true - } - }, "@metamask/gas-fee-controller>@metamask/polling-controller": { "globals": { "clearTimeout": true, @@ -1454,7 +1446,7 @@ "setTimeout": true }, "packages": { - "@metamask/gas-fee-controller>@metamask/base-controller": true, + "@metamask/base-controller": true, "@metamask/snaps-utils>fast-json-stable-stringify": true, "uuid": true } @@ -2173,82 +2165,16 @@ "console.error": true }, "packages": { + "@metamask/base-controller": true, "@metamask/controller-utils": true, - "@metamask/permission-controller>@metamask/base-controller": true, - "@metamask/permission-controller>@metamask/json-rpc-engine": true, - "@metamask/permission-controller>@metamask/rpc-errors": true, - "@metamask/permission-controller>@metamask/utils": true, + "@metamask/json-rpc-engine": true, "@metamask/permission-controller>nanoid": true, + "@metamask/rpc-errors": true, + "@metamask/utils": true, "deep-freeze-strict": true, "immer": true } }, - "@metamask/permission-controller>@metamask/base-controller": { - "globals": { - "setTimeout": true - }, - "packages": { - "immer": true - } - }, - "@metamask/permission-controller>@metamask/json-rpc-engine": { - "packages": { - "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/utils": true, - "@metamask/permission-controller>@metamask/rpc-errors": true, - "@metamask/safe-event-emitter": true - } - }, - "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>@metamask/superstruct": true, - "@metamask/utils>@scure/base": true, - "@metamask/utils>pony-cause": true, - "@noble/hashes": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, - "@metamask/permission-controller>@metamask/rpc-errors": { - "packages": { - "@metamask/permission-controller>@metamask/rpc-errors>@metamask/utils": true, - "@metamask/rpc-errors>fast-safe-stringify": true - } - }, - "@metamask/permission-controller>@metamask/rpc-errors>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>@metamask/superstruct": true, - "@metamask/utils>@scure/base": true, - "@metamask/utils>pony-cause": true, - "@noble/hashes": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, - "@metamask/permission-controller>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>@metamask/superstruct": true, - "@metamask/utils>@scure/base": true, - "@metamask/utils>pony-cause": true, - "@noble/hashes": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, "@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -2703,13 +2629,13 @@ "@ethersproject/providers": true, "@metamask/controller-utils": true, "@metamask/eth-query": true, - "@metamask/gas-fee-controller": true, "@metamask/metamask-eth-abis": true, "@metamask/name-controller>async-mutex": true, "@metamask/network-controller": true, "@metamask/smart-transactions-controller>@metamask/base-controller": true, "@metamask/smart-transactions-controller>@metamask/transaction-controller>@ethereumjs/tx": true, "@metamask/smart-transactions-controller>@metamask/transaction-controller>@ethereumjs/util": true, + "@metamask/smart-transactions-controller>@metamask/transaction-controller>@metamask/gas-fee-controller": true, "@metamask/smart-transactions-controller>@metamask/transaction-controller>@metamask/nonce-tracker": true, "@metamask/smart-transactions-controller>@metamask/transaction-controller>@metamask/rpc-errors": true, "@metamask/smart-transactions-controller>@metamask/transaction-controller>@metamask/utils": true, @@ -2750,6 +2676,20 @@ "webpack>events": true } }, + "@metamask/smart-transactions-controller>@metamask/transaction-controller>@metamask/gas-fee-controller": { + "globals": { + "clearInterval": true, + "console.error": true, + "setInterval": true + }, + "packages": { + "@metamask/controller-utils": true, + "@metamask/eth-query": true, + "@metamask/smart-transactions-controller>@metamask/polling-controller": true, + "bn.js": true, + "uuid": true + } + }, "@metamask/smart-transactions-controller>@metamask/transaction-controller>@metamask/nonce-tracker": { "packages": { "@ethersproject/providers": true, @@ -2822,9 +2762,9 @@ "@metamask/json-rpc-engine": true, "@metamask/json-rpc-middleware-stream": true, "@metamask/object-multiplex": true, + "@metamask/permission-controller": true, "@metamask/post-message-stream": true, "@metamask/rpc-errors": true, - "@metamask/snaps-controllers>@metamask/permission-controller": true, "@metamask/snaps-controllers>@xstate/fsm": true, "@metamask/snaps-controllers>concat-stream": true, "@metamask/snaps-controllers>get-npm-tarball-url": true, @@ -2848,21 +2788,6 @@ "crypto.getRandomValues": true } }, - "@metamask/snaps-controllers>@metamask/permission-controller": { - "globals": { - "console.error": true - }, - "packages": { - "@metamask/base-controller": true, - "@metamask/controller-utils": true, - "@metamask/json-rpc-engine": true, - "@metamask/rpc-errors": true, - "@metamask/snaps-controllers>nanoid": true, - "@metamask/utils": true, - "deep-freeze-strict": true, - "immer": true - } - }, "@metamask/snaps-controllers>concat-stream": { "packages": { "browserify>buffer": true, @@ -2920,8 +2845,8 @@ }, "@metamask/snaps-rpc-methods": { "packages": { + "@metamask/permission-controller": true, "@metamask/rpc-errors": true, - "@metamask/snaps-rpc-methods>@metamask/permission-controller": true, "@metamask/snaps-sdk": true, "@metamask/snaps-sdk>@metamask/key-tree": true, "@metamask/snaps-utils": true, @@ -2930,26 +2855,6 @@ "@noble/hashes": true } }, - "@metamask/snaps-rpc-methods>@metamask/permission-controller": { - "globals": { - "console.error": true - }, - "packages": { - "@metamask/base-controller": true, - "@metamask/controller-utils": true, - "@metamask/json-rpc-engine": true, - "@metamask/rpc-errors": true, - "@metamask/snaps-rpc-methods>@metamask/permission-controller>nanoid": true, - "@metamask/utils": true, - "deep-freeze-strict": true, - "immer": true - } - }, - "@metamask/snaps-rpc-methods>@metamask/permission-controller>nanoid": { - "globals": { - "crypto.getRandomValues": true - } - }, "@metamask/snaps-sdk": { "globals": { "fetch": true @@ -3000,10 +2905,10 @@ "fetch": true }, "packages": { + "@metamask/permission-controller": true, "@metamask/rpc-errors": true, "@metamask/snaps-sdk": true, "@metamask/snaps-sdk>@metamask/key-tree": true, - "@metamask/snaps-utils>@metamask/permission-controller": true, "@metamask/snaps-utils>@metamask/slip44": true, "@metamask/snaps-utils>cron-parser": true, "@metamask/snaps-utils>fast-json-stable-stringify": true, @@ -3019,26 +2924,6 @@ "semver": true } }, - "@metamask/snaps-utils>@metamask/permission-controller": { - "globals": { - "console.error": true - }, - "packages": { - "@metamask/base-controller": true, - "@metamask/controller-utils": true, - "@metamask/json-rpc-engine": true, - "@metamask/rpc-errors": true, - "@metamask/snaps-utils>@metamask/permission-controller>nanoid": true, - "@metamask/utils": true, - "deep-freeze-strict": true, - "immer": true - } - }, - "@metamask/snaps-utils>@metamask/permission-controller>nanoid": { - "globals": { - "crypto.getRandomValues": true - } - }, "@metamask/snaps-utils>@metamask/snaps-registry": { "packages": { "@metamask/message-signing-snap>@noble/curves": true, @@ -3144,29 +3029,21 @@ "fetch": true }, "packages": { + "@metamask/base-controller": true, "@metamask/controller-utils": true, "@metamask/eth-query": true, "@metamask/gas-fee-controller": true, + "@metamask/rpc-errors": true, "@metamask/transaction-controller": true, - "@metamask/user-operation-controller>@metamask/base-controller": true, "@metamask/user-operation-controller>@metamask/polling-controller": true, - "@metamask/user-operation-controller>@metamask/rpc-errors": true, "@metamask/user-operation-controller>@metamask/utils": true, + "@metamask/utils>@metamask/superstruct": true, "bn.js": true, "lodash": true, - "superstruct": true, "uuid": true, "webpack>events": true } }, - "@metamask/user-operation-controller>@metamask/base-controller": { - "globals": { - "setTimeout": true - }, - "packages": { - "immer": true - } - }, "@metamask/user-operation-controller>@metamask/polling-controller": { "globals": { "clearTimeout": true, @@ -3174,32 +3051,11 @@ "setTimeout": true }, "packages": { + "@metamask/base-controller": true, "@metamask/snaps-utils>fast-json-stable-stringify": true, - "@metamask/user-operation-controller>@metamask/base-controller": true, "uuid": true } }, - "@metamask/user-operation-controller>@metamask/rpc-errors": { - "packages": { - "@metamask/rpc-errors>fast-safe-stringify": true, - "@metamask/user-operation-controller>@metamask/rpc-errors>@metamask/utils": true - } - }, - "@metamask/user-operation-controller>@metamask/rpc-errors>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>@metamask/superstruct": true, - "@metamask/utils>@scure/base": true, - "@metamask/utils>pony-cause": true, - "@noble/hashes": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, "@metamask/user-operation-controller>@metamask/utils": { "globals": { "TextDecoder": true, @@ -5789,12 +5645,6 @@ "string.prototype.matchall>get-intrinsic": true } }, - "superstruct": { - "globals": { - "console.warn": true, - "define": true - } - }, "terser>source-map-support>buffer-from": { "packages": { "browserify>buffer": true diff --git a/lavamoat/browserify/mmi/policy.json b/lavamoat/browserify/mmi/policy.json index a604526f155d..e70102a63e51 100644 --- a/lavamoat/browserify/mmi/policy.json +++ b/lavamoat/browserify/mmi/policy.json @@ -1531,14 +1531,6 @@ "uuid": true } }, - "@metamask/gas-fee-controller>@metamask/base-controller": { - "globals": { - "setTimeout": true - }, - "packages": { - "immer": true - } - }, "@metamask/gas-fee-controller>@metamask/polling-controller": { "globals": { "clearTimeout": true, @@ -1546,7 +1538,7 @@ "setTimeout": true }, "packages": { - "@metamask/gas-fee-controller>@metamask/base-controller": true, + "@metamask/base-controller": true, "@metamask/snaps-utils>fast-json-stable-stringify": true, "uuid": true } @@ -2265,82 +2257,16 @@ "console.error": true }, "packages": { + "@metamask/base-controller": true, "@metamask/controller-utils": true, - "@metamask/permission-controller>@metamask/base-controller": true, - "@metamask/permission-controller>@metamask/json-rpc-engine": true, - "@metamask/permission-controller>@metamask/rpc-errors": true, - "@metamask/permission-controller>@metamask/utils": true, + "@metamask/json-rpc-engine": true, "@metamask/permission-controller>nanoid": true, + "@metamask/rpc-errors": true, + "@metamask/utils": true, "deep-freeze-strict": true, "immer": true } }, - "@metamask/permission-controller>@metamask/base-controller": { - "globals": { - "setTimeout": true - }, - "packages": { - "immer": true - } - }, - "@metamask/permission-controller>@metamask/json-rpc-engine": { - "packages": { - "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/utils": true, - "@metamask/permission-controller>@metamask/rpc-errors": true, - "@metamask/safe-event-emitter": true - } - }, - "@metamask/permission-controller>@metamask/json-rpc-engine>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>@metamask/superstruct": true, - "@metamask/utils>@scure/base": true, - "@metamask/utils>pony-cause": true, - "@noble/hashes": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, - "@metamask/permission-controller>@metamask/rpc-errors": { - "packages": { - "@metamask/permission-controller>@metamask/rpc-errors>@metamask/utils": true, - "@metamask/rpc-errors>fast-safe-stringify": true - } - }, - "@metamask/permission-controller>@metamask/rpc-errors>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>@metamask/superstruct": true, - "@metamask/utils>@scure/base": true, - "@metamask/utils>pony-cause": true, - "@noble/hashes": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, - "@metamask/permission-controller>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>@metamask/superstruct": true, - "@metamask/utils>@scure/base": true, - "@metamask/utils>pony-cause": true, - "@noble/hashes": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, "@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -2795,13 +2721,13 @@ "@ethersproject/providers": true, "@metamask/controller-utils": true, "@metamask/eth-query": true, - "@metamask/gas-fee-controller": true, "@metamask/metamask-eth-abis": true, "@metamask/name-controller>async-mutex": true, "@metamask/network-controller": true, "@metamask/smart-transactions-controller>@metamask/base-controller": true, "@metamask/smart-transactions-controller>@metamask/transaction-controller>@ethereumjs/tx": true, "@metamask/smart-transactions-controller>@metamask/transaction-controller>@ethereumjs/util": true, + "@metamask/smart-transactions-controller>@metamask/transaction-controller>@metamask/gas-fee-controller": true, "@metamask/smart-transactions-controller>@metamask/transaction-controller>@metamask/nonce-tracker": true, "@metamask/smart-transactions-controller>@metamask/transaction-controller>@metamask/rpc-errors": true, "@metamask/smart-transactions-controller>@metamask/transaction-controller>@metamask/utils": true, @@ -2842,6 +2768,20 @@ "webpack>events": true } }, + "@metamask/smart-transactions-controller>@metamask/transaction-controller>@metamask/gas-fee-controller": { + "globals": { + "clearInterval": true, + "console.error": true, + "setInterval": true + }, + "packages": { + "@metamask/controller-utils": true, + "@metamask/eth-query": true, + "@metamask/smart-transactions-controller>@metamask/polling-controller": true, + "bn.js": true, + "uuid": true + } + }, "@metamask/smart-transactions-controller>@metamask/transaction-controller>@metamask/nonce-tracker": { "packages": { "@ethersproject/providers": true, @@ -2914,9 +2854,9 @@ "@metamask/json-rpc-engine": true, "@metamask/json-rpc-middleware-stream": true, "@metamask/object-multiplex": true, + "@metamask/permission-controller": true, "@metamask/post-message-stream": true, "@metamask/rpc-errors": true, - "@metamask/snaps-controllers>@metamask/permission-controller": true, "@metamask/snaps-controllers>@xstate/fsm": true, "@metamask/snaps-controllers>concat-stream": true, "@metamask/snaps-controllers>get-npm-tarball-url": true, @@ -2940,21 +2880,6 @@ "crypto.getRandomValues": true } }, - "@metamask/snaps-controllers>@metamask/permission-controller": { - "globals": { - "console.error": true - }, - "packages": { - "@metamask/base-controller": true, - "@metamask/controller-utils": true, - "@metamask/json-rpc-engine": true, - "@metamask/rpc-errors": true, - "@metamask/snaps-controllers>nanoid": true, - "@metamask/utils": true, - "deep-freeze-strict": true, - "immer": true - } - }, "@metamask/snaps-controllers>concat-stream": { "packages": { "browserify>buffer": true, @@ -3012,8 +2937,8 @@ }, "@metamask/snaps-rpc-methods": { "packages": { + "@metamask/permission-controller": true, "@metamask/rpc-errors": true, - "@metamask/snaps-rpc-methods>@metamask/permission-controller": true, "@metamask/snaps-sdk": true, "@metamask/snaps-sdk>@metamask/key-tree": true, "@metamask/snaps-utils": true, @@ -3022,26 +2947,6 @@ "@noble/hashes": true } }, - "@metamask/snaps-rpc-methods>@metamask/permission-controller": { - "globals": { - "console.error": true - }, - "packages": { - "@metamask/base-controller": true, - "@metamask/controller-utils": true, - "@metamask/json-rpc-engine": true, - "@metamask/rpc-errors": true, - "@metamask/snaps-rpc-methods>@metamask/permission-controller>nanoid": true, - "@metamask/utils": true, - "deep-freeze-strict": true, - "immer": true - } - }, - "@metamask/snaps-rpc-methods>@metamask/permission-controller>nanoid": { - "globals": { - "crypto.getRandomValues": true - } - }, "@metamask/snaps-sdk": { "globals": { "fetch": true @@ -3092,10 +2997,10 @@ "fetch": true }, "packages": { + "@metamask/permission-controller": true, "@metamask/rpc-errors": true, "@metamask/snaps-sdk": true, "@metamask/snaps-sdk>@metamask/key-tree": true, - "@metamask/snaps-utils>@metamask/permission-controller": true, "@metamask/snaps-utils>@metamask/slip44": true, "@metamask/snaps-utils>cron-parser": true, "@metamask/snaps-utils>fast-json-stable-stringify": true, @@ -3111,26 +3016,6 @@ "semver": true } }, - "@metamask/snaps-utils>@metamask/permission-controller": { - "globals": { - "console.error": true - }, - "packages": { - "@metamask/base-controller": true, - "@metamask/controller-utils": true, - "@metamask/json-rpc-engine": true, - "@metamask/rpc-errors": true, - "@metamask/snaps-utils>@metamask/permission-controller>nanoid": true, - "@metamask/utils": true, - "deep-freeze-strict": true, - "immer": true - } - }, - "@metamask/snaps-utils>@metamask/permission-controller>nanoid": { - "globals": { - "crypto.getRandomValues": true - } - }, "@metamask/snaps-utils>@metamask/snaps-registry": { "packages": { "@metamask/message-signing-snap>@noble/curves": true, @@ -3236,29 +3121,21 @@ "fetch": true }, "packages": { + "@metamask/base-controller": true, "@metamask/controller-utils": true, "@metamask/eth-query": true, "@metamask/gas-fee-controller": true, + "@metamask/rpc-errors": true, "@metamask/transaction-controller": true, - "@metamask/user-operation-controller>@metamask/base-controller": true, "@metamask/user-operation-controller>@metamask/polling-controller": true, - "@metamask/user-operation-controller>@metamask/rpc-errors": true, "@metamask/user-operation-controller>@metamask/utils": true, + "@metamask/utils>@metamask/superstruct": true, "bn.js": true, "lodash": true, - "superstruct": true, "uuid": true, "webpack>events": true } }, - "@metamask/user-operation-controller>@metamask/base-controller": { - "globals": { - "setTimeout": true - }, - "packages": { - "immer": true - } - }, "@metamask/user-operation-controller>@metamask/polling-controller": { "globals": { "clearTimeout": true, @@ -3266,32 +3143,11 @@ "setTimeout": true }, "packages": { + "@metamask/base-controller": true, "@metamask/snaps-utils>fast-json-stable-stringify": true, - "@metamask/user-operation-controller>@metamask/base-controller": true, "uuid": true } }, - "@metamask/user-operation-controller>@metamask/rpc-errors": { - "packages": { - "@metamask/rpc-errors>fast-safe-stringify": true, - "@metamask/user-operation-controller>@metamask/rpc-errors>@metamask/utils": true - } - }, - "@metamask/user-operation-controller>@metamask/rpc-errors>@metamask/utils": { - "globals": { - "TextDecoder": true, - "TextEncoder": true - }, - "packages": { - "@metamask/utils>@metamask/superstruct": true, - "@metamask/utils>@scure/base": true, - "@metamask/utils>pony-cause": true, - "@noble/hashes": true, - "browserify>buffer": true, - "nock>debug": true, - "semver": true - } - }, "@metamask/user-operation-controller>@metamask/utils": { "globals": { "TextDecoder": true, @@ -5857,12 +5713,6 @@ "string.prototype.matchall>get-intrinsic": true } }, - "superstruct": { - "globals": { - "console.warn": true, - "define": true - } - }, "terser>source-map-support>buffer-from": { "packages": { "browserify>buffer": true diff --git a/package.json b/package.json index b7adb1fcdcee..5304df2c2ff8 100644 --- a/package.json +++ b/package.json @@ -241,7 +241,6 @@ "@expo/config-plugins/glob": "^10.3.10", "@solana/web3.js/rpc-websockets": "^8.0.1", "@metamask/message-manager": "^10.1.0", - "@metamask/gas-fee-controller@npm:^15.1.1": "patch:@metamask/gas-fee-controller@npm%3A15.1.2#~/.yarn/patches/@metamask-gas-fee-controller-npm-15.1.2-db4d2976aa.patch", "@metamask/nonce-tracker@npm:^5.0.0": "patch:@metamask/nonce-tracker@npm%3A5.0.0#~/.yarn/patches/@metamask-nonce-tracker-npm-5.0.0-d81478218e.patch", "@metamask/network-controller@npm:^17.0.0": "patch:@metamask/network-controller@npm%3A21.0.0#~/.yarn/patches/@metamask-network-controller-npm-21.0.0-559aa8e395.patch", "@metamask/network-controller@npm:^19.0.0": "patch:@metamask/network-controller@npm%3A21.0.0#~/.yarn/patches/@metamask-network-controller-npm-21.0.0-559aa8e395.patch", @@ -310,7 +309,7 @@ "@metamask/ethjs": "^0.6.0", "@metamask/ethjs-contract": "^0.4.1", "@metamask/ethjs-query": "^0.7.1", - "@metamask/gas-fee-controller": "^18.0.0", + "@metamask/gas-fee-controller": "^21.0.0", "@metamask/jazzicon": "^2.0.0", "@metamask/json-rpc-engine": "^10.0.0", "@metamask/json-rpc-middleware-stream": "^8.0.4", @@ -327,7 +326,7 @@ "@metamask/notification-services-controller": "^0.14.0", "@metamask/object-multiplex": "^2.0.0", "@metamask/obs-store": "^9.0.0", - "@metamask/permission-controller": "^10.0.0", + "@metamask/permission-controller": "^11.0.0", "@metamask/permission-log-controller": "^2.0.1", "@metamask/phishing-controller": "^12.3.0", "@metamask/polling-controller": "^10.0.1", @@ -351,7 +350,7 @@ "@metamask/snaps-utils": "^8.6.0", "@metamask/solana-wallet-snap": "^0.1.9", "@metamask/transaction-controller": "^40.1.0", - "@metamask/user-operation-controller": "^13.0.0", + "@metamask/user-operation-controller": "^16.0.0", "@metamask/utils": "^10.0.1", "@ngraveio/bc-ur": "^1.1.12", "@noble/hashes": "^1.3.3", diff --git a/shared/constants/metametrics.ts b/shared/constants/metametrics.ts index 760e3c26a31f..c87af10544c3 100644 --- a/shared/constants/metametrics.ts +++ b/shared/constants/metametrics.ts @@ -594,6 +594,10 @@ export enum MetaMetricsUserTrait { * Identifies if the Privacy Mode is enabled */ PrivacyModeEnabled = 'privacy_mode_toggle', + /** + * Identified when the user prefers to see all tokens or current network tokens in wallet list + */ + NetworkFilterPreference = 'selected_network_filter', } /** diff --git a/test/e2e/page-objects/pages/account-list-page.ts b/test/e2e/page-objects/pages/account-list-page.ts index 9f96d70f4972..5660dc616279 100644 --- a/test/e2e/page-objects/pages/account-list-page.ts +++ b/test/e2e/page-objects/pages/account-list-page.ts @@ -11,6 +11,9 @@ class AccountListPage { private readonly accountListBalance = '[data-testid="second-currency-display"]'; + private readonly accountValueAndSuffix = + '[data-testid="account-value-and-suffix"]'; + private readonly accountListItem = '.multichain-account-menu-popover__list--menu-item'; @@ -345,6 +348,23 @@ class AccountListPage { ); } + /** + * Checks that the account value and suffix is displayed in the account list. + * + * @param expectedValueAndSuffix - The expected value and suffix to check. + */ + async check_accountValueAndSuffixDisplayed( + expectedValueAndSuffix: string, + ): Promise { + console.log( + `Check that account value and suffix ${expectedValueAndSuffix} is displayed in account list`, + ); + await this.driver.waitForSelector({ + css: this.accountValueAndSuffix, + text: expectedValueAndSuffix, + }); + } + async openAccountOptionsMenu(): Promise { console.log(`Open account option menu`); await this.driver.waitForSelector(this.accountListItem); diff --git a/test/e2e/page-objects/pages/asset-list.ts b/test/e2e/page-objects/pages/asset-list.ts new file mode 100644 index 000000000000..6d6d8af391bd --- /dev/null +++ b/test/e2e/page-objects/pages/asset-list.ts @@ -0,0 +1,172 @@ +import { Driver } from '../../webdriver/driver'; + +class AssetListPage { + private readonly driver: Driver; + + private readonly allNetworksOption = + '[data-testid="network-filter-all__button"]'; + + private readonly currentNetworkOption = + '[data-testid="network-filter-current__button"]'; + + private readonly networksToggle = '[data-testid="sort-by-networks"]'; + + private readonly allNetworksTotal = + '[data-testid="network-filter-all__total"]'; + + private readonly currentNetworksTotal = `${this.currentNetworkOption} [data-testid="account-value-and-suffix"]`; + + constructor(driver: Driver) { + this.driver = driver; + } + + async checkNetworkFilterText(expectedText: string): Promise { + console.log( + `Verify the displayed account label in header is: ${expectedText}`, + ); + await this.driver.waitForSelector({ + css: this.networksToggle, + text: expectedText, + }); + } + + async openNetworksFilter(): Promise { + console.log(`Opening the network filter`); + await this.driver.clickElement(this.networksToggle); + await this.driver.waitUntil( + async () => { + return await this.driver.findElement(this.allNetworksOption); + }, + { + timeout: 5000, + interval: 100, + }, + ); + } + + async getNetworksFilterLabel(): Promise { + console.log(`Retrieving the network filter label`); + const toggle = await this.driver.findElement(this.networksToggle); + const text = await toggle.getText(); + return text; + } + + async clickCurrentNetworkOption(): Promise { + console.log(`Clicking on the current network option`); + await this.driver.clickElement(this.currentNetworkOption); + + await this.driver.waitUntil( + async () => { + const label = await this.getNetworksFilterLabel(); + return label !== 'All networks'; + }, + { timeout: 5000, interval: 100 }, + ); + } + + async waitUntilAssetListHasItems(expectedItemsCount: number): Promise { + console.log(`Waiting until the asset list has ${expectedItemsCount} items`); + await this.driver.waitUntil( + async () => { + const items = await this.getNumberOfAssets(); + return items === expectedItemsCount; + }, + { timeout: 5000, interval: 100 }, + ); + } + + async waitUntilFilterLabelIs(label: string): Promise { + console.log(`Waiting until the filter label is ${label}`); + await this.driver.waitUntil( + async () => { + const currentLabel = await this.getNetworksFilterLabel(); + return currentLabel === label; + }, + { timeout: 5000, interval: 100 }, + ); + } + + async getAllNetworksOptionTotal(): Promise { + console.log(`Retrieving the "All networks" option fiat value`); + const allNetworksValueElement = await this.driver.findElement( + this.allNetworksTotal, + ); + const value = await allNetworksValueElement.getText(); + return value; + } + + async clickOnAsset(assetName: string): Promise { + const buttons = await this.driver.findElements( + '[data-testid="multichain-token-list-button"]', + ); + + for (const button of buttons) { + const text = await button.getText(); + if (text.includes(assetName)) { + await button.click(); + return; + } + } + + throw new Error(`${assetName} button not found`); + } + + async getCurrentNetworksOptionTotal(): Promise { + console.log(`Retrieving the "Current network" option fiat value`); + const allNetworksValueElement = await this.driver.findElement( + this.currentNetworksTotal, + ); + const value = await allNetworksValueElement.getText(); + return value; + } + + async selectNetworkFilterAllNetworks(): Promise { + console.log(`Selecting "All networks" from the network filter`); + await this.driver.clickElement(this.allNetworksOption); + + await this.driver.waitUntil( + async () => { + const label = await this.getNetworksFilterLabel(); + return label === 'All networks'; + }, + { timeout: 5000, interval: 100 }, + ); + } + + async selectNetworkFilterCurrentNetwork(): Promise { + console.log(`Selecting "Current network" from the network filter`); + await this.driver.clickElement(this.currentNetworkOption); + + await this.driver.waitUntil( + async () => { + const label = await this.getNetworksFilterLabel(); + return label !== 'All networks'; + }, + { timeout: 5000, interval: 100 }, + ); + } + + async getNumberOfAssets(): Promise { + console.log(`Returning the total number of asset items in the token list`); + const assets = await this.driver.findElements( + '.multichain-token-list-item', + ); + return assets.length; + } + + // Added method to check if an asset is visible + async isAssetVisible(assetName: string): Promise { + const assets = await this.driver.findElements( + '[data-testid="multichain-token-list-button"]', + ); + for (const asset of assets) { + const text = await asset.getText(); + if (text.includes(assetName)) { + return true; + } + } + return false; + } +} + +export default AssetListPage; diff --git a/test/e2e/page-objects/pages/homepage.ts b/test/e2e/page-objects/pages/homepage.ts index c5c4d5369d4e..889ab344d91a 100644 --- a/test/e2e/page-objects/pages/homepage.ts +++ b/test/e2e/page-objects/pages/homepage.ts @@ -61,6 +61,8 @@ class HomePage { private readonly nftTab = '[data-testid="account-overview__nfts-tab"]'; + private readonly popoverCloseButton = '[data-testid="popover-close"]'; + private readonly successImportNftMessage = { text: 'NFT was successfully added!', tag: 'h6', @@ -85,6 +87,11 @@ class HomePage { console.log('Home page is loaded'); } + async closePopover(): Promise { + console.log('Closing popover'); + await this.driver.clickElement(this.popoverCloseButton); + } + async closeUseNetworkNotificationModal(): Promise { // We need to use clickElementSafe + assertElementNotPresent as sometimes the network dialog doesn't appear, as per this issue (#25788) // TODO: change the 2 actions for clickElementAndWaitToDisappear, once the issue is fixed @@ -240,24 +247,26 @@ class HomePage { * Checks if the expected balance is displayed on homepage. * * @param expectedBalance - The expected balance to be displayed. Defaults to '0'. + * @param symbol - The symbol of the currency or token. Defaults to 'ETH'. */ async check_expectedBalanceIsDisplayed( expectedBalance: string = '0', + symbol: string = 'ETH', ): Promise { try { await this.driver.waitForSelector({ css: this.balance, - text: `${expectedBalance} ETH`, + text: expectedBalance, }); } catch (e) { const balance = await this.driver.waitForSelector(this.balance); const currentBalance = parseFloat(await balance.getText()); - const errorMessage = `Expected balance ${expectedBalance} ETH, got balance ${currentBalance} ETH`; + const errorMessage = `Expected balance ${expectedBalance} ${symbol}, got balance ${currentBalance} ${symbol}`; console.log(errorMessage, e); throw e; } console.log( - `Expected balance ${expectedBalance} ETH is displayed on homepage`, + `Expected balance ${expectedBalance} ${symbol} is displayed on homepage`, ); } diff --git a/test/e2e/page-objects/pages/send/send-token-page.ts b/test/e2e/page-objects/pages/send/send-token-page.ts index 29222ed3d48c..3c1d96618556 100644 --- a/test/e2e/page-objects/pages/send/send-token-page.ts +++ b/test/e2e/page-objects/pages/send/send-token-page.ts @@ -1,4 +1,5 @@ import { strict as assert } from 'assert'; +import { WebElement } from 'selenium-webdriver'; import { Driver } from '../../../webdriver/driver'; class SendTokenPage { @@ -11,11 +12,18 @@ class SendTokenPage { tag: 'button', }; + private readonly cancelButton = { + text: 'Cancel', + tag: 'button', + }; + private readonly ensAddressAsRecipient = '[data-testid="ens-input-selected"]'; private readonly ensResolvedName = '[data-testid="multichain-send-page__recipient__item__title"]'; + private readonly assetValue = '[data-testid="account-value-and-suffix"]'; + private readonly inputAmount = '[data-testid="currency-input"]'; private readonly inputNFTAmount = '[data-testid="nft-input"]'; @@ -30,10 +38,17 @@ class SendTokenPage { private readonly tokenListButton = '[data-testid="multichain-token-list-button"]'; + private readonly toastText = '.toast-text'; + constructor(driver: Driver) { this.driver = driver; } + async getAssetPickerItems(): Promise { + console.log('Retrieving asset picker items'); + return this.driver.findElements(this.tokenListButton); + } + async check_pageIsLoaded(): Promise { try { await this.driver.waitForMultipleSelectors([ @@ -59,6 +74,22 @@ class SendTokenPage { await elements[1].click(); } + async checkAccountValueAndSuffix(value: string): Promise { + console.log(`Checking if account value and suffix is ${value}`); + const element = await this.driver.waitForSelector(this.assetValue); + const text = await element.getText(); + assert.equal( + text, + value, + `Expected account value and suffix to be ${value}, got ${text}`, + ); + console.log(`Account value and suffix is ${value}`); + } + + async clickCancelButton(): Promise { + await this.driver.clickElement(this.cancelButton); + } + async fillAmount(amount: string): Promise { console.log(`Fill amount input with ${amount} on send token screen`); const inputAmount = await this.driver.waitForSelector(this.inputAmount); @@ -74,6 +105,16 @@ class SendTokenPage { ); } + async check_networkChange(networkName: string): Promise { + const toastTextElement = await this.driver.findElement(this.toastText); + const toastText = await toastTextElement.getText(); + assert.equal( + toastText, + `You're now using ${networkName}`, + 'Toast text is correct', + ); + } + async fillNFTAmount(amount: string) { await this.driver.pasteIntoField(this.inputNFTAmount, amount); } diff --git a/test/e2e/page-objects/pages/settings/settings-page.ts b/test/e2e/page-objects/pages/settings/settings-page.ts index d103aca83f97..4444556a1b74 100644 --- a/test/e2e/page-objects/pages/settings/settings-page.ts +++ b/test/e2e/page-objects/pages/settings/settings-page.ts @@ -40,6 +40,35 @@ class SettingsPage { console.log('Settings page is loaded'); } + async clickAdvancedTab(): Promise { + console.log('Clicking on Advanced tab'); + await this.driver.clickElement({ + css: '.tab-bar__tab__content__title', + text: 'Advanced', + }); + } + + async toggleShowFiatOnTestnets(): Promise { + console.log('Toggling Show Fiat on Testnets setting'); + await this.driver.clickElement( + '.toggle-button.show-fiat-on-testnets-toggle', + ); + } + + async toggleBalanceSetting(): Promise { + console.log('Toggling balance setting'); + await this.driver.clickElement( + '.toggle-button.show-native-token-as-main-balance', + ); + } + + async exitSettings(): Promise { + console.log('Exiting settings page'); + await this.driver.clickElement( + '.settings-page__header__title-container__close-button', + ); + } + async closeSettingsPage(): Promise { console.log('Closing Settings page'); await this.driver.clickElement(this.closeSettingsPageButton); diff --git a/test/e2e/tests/multichain/aggregated-balances.spec.ts b/test/e2e/tests/multichain/aggregated-balances.spec.ts new file mode 100644 index 000000000000..57df2362b236 --- /dev/null +++ b/test/e2e/tests/multichain/aggregated-balances.spec.ts @@ -0,0 +1,137 @@ +import { strict as assert } from 'assert'; +import { Suite } from 'mocha'; +import { Driver } from '../../webdriver/driver'; +import { withFixtures, defaultGanacheOptions } from '../../helpers'; +import FixtureBuilder from '../../fixture-builder'; +import { Ganache } from '../../seeder/ganache'; +import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow'; +import { SMART_CONTRACTS } from '../../seeder/smart-contracts'; +import HeaderNavbar from '../../page-objects/pages/header-navbar'; +import SelectNetwork from '../../page-objects/pages/dialog/select-network'; +import HomePage from '../../page-objects/pages/homepage'; +import SettingsPage from '../../page-objects/pages/settings/settings-page'; +import AccountListPage from '../../page-objects/pages/account-list-page'; +import AssetListPage from '../../page-objects/pages/asset-list'; +import SendTokenPage from '../../page-objects/pages/send/send-token-page'; + +const EXPECTED_MAINNET_BALANCE_USD = '$84,985.04'; +const EXPECTED_CURRENT_NETWORK_BALANCE_USD = '$42,492.52'; +const EXPECTED_SEPOLIA_BALANCE_NATIVE = '24.9956'; +const NETWORK_NAME_MAINNET = 'Ethereum Mainnet'; +const NETWORK_NAME_SEPOLIA = 'Sepolia'; +const SEPOLIA_NATIVE_TOKEN = 'SepoliaETH'; + +describe('Multichain Aggregated Balances', function (this: Suite) { + if (!process.env.PORTFOLIO_VIEW) { + return; + } + + it('shows correct aggregated balance when "Current Network" is selected', async function () { + await withFixtures( + { + fixtures: new FixtureBuilder() + .withPermissionControllerConnectedToTestDapp() + .withTokensControllerERC20() + .build(), + ganacheOptions: defaultGanacheOptions, + smartContract: SMART_CONTRACTS.HST, + title: this.test?.fullTitle(), + }, + async ({ + driver, + ganacheServer, + }: { + driver: Driver; + ganacheServer?: Ganache; + }) => { + // Step 1: Log in and set up page objects + await loginWithBalanceValidation(driver, ganacheServer); + + const homepage = new HomePage(driver); + const headerNavbar = new HeaderNavbar(driver); + const selectNetworkDialog = new SelectNetwork(driver); + const settingsPage = new SettingsPage(driver); + const accountListPage = new AccountListPage(driver); + const assetListPage = new AssetListPage(driver); + const sendTokenPage = new SendTokenPage(driver); + + // Step 2: Switch to Ethereum Mainnet + await headerNavbar.clickSwitchNetworkDropDown(); + await selectNetworkDialog.selectNetworkName(NETWORK_NAME_MAINNET); + + // Step 3: Enable fiat balance display in settings + await headerNavbar.openSettingsPage(); + await settingsPage.toggleBalanceSetting(); + await settingsPage.exitSettings(); + + // Step 4: Verify main balance on homepage and account menu + await homepage.check_expectedBalanceIsDisplayed( + EXPECTED_MAINNET_BALANCE_USD, + 'usd', + ); + await headerNavbar.openAccountMenu(); + await accountListPage.check_accountValueAndSuffixDisplayed( + EXPECTED_MAINNET_BALANCE_USD, + ); + await accountListPage.closeAccountModal(); + + // Step 5: Verify balance in send flow + await homepage.closePopover(); + await homepage.startSendFlow(); + await sendTokenPage.checkAccountValueAndSuffix( + EXPECTED_MAINNET_BALANCE_USD, + ); + await sendTokenPage.clickCancelButton(); + + // Step 6: Check balance for "Current Network" in network filter + await assetListPage.openNetworksFilter(); + const networkFilterTotal = + await assetListPage.getCurrentNetworksOptionTotal(); + assert.equal(networkFilterTotal, EXPECTED_CURRENT_NETWORK_BALANCE_USD); + await assetListPage.clickCurrentNetworkOption(); + + // Step 7: Verify balance after selecting "Current Network" + await homepage.check_expectedBalanceIsDisplayed( + EXPECTED_CURRENT_NETWORK_BALANCE_USD, + 'usd', + ); + await headerNavbar.openAccountMenu(); + await accountListPage.check_accountValueAndSuffixDisplayed( + EXPECTED_CURRENT_NETWORK_BALANCE_USD, + ); + await accountListPage.closeAccountModal(); + + // Step 8: Verify balance in send flow after selecting "Current Network" + await homepage.startSendFlow(); + await sendTokenPage.checkAccountValueAndSuffix( + EXPECTED_CURRENT_NETWORK_BALANCE_USD, + ); + await sendTokenPage.clickCancelButton(); + + // Step 9: Switch to Sepolia test network + await headerNavbar.clickSwitchNetworkDropDown(); + await driver.clickElement('.toggle-button'); + await driver.clickElement({ text: NETWORK_NAME_SEPOLIA, tag: 'p' }); + + // Step 10: Verify native balance on Sepolia network + await homepage.check_expectedBalanceIsDisplayed( + EXPECTED_SEPOLIA_BALANCE_NATIVE, + SEPOLIA_NATIVE_TOKEN, + ); + await assetListPage.checkNetworkFilterText(NETWORK_NAME_SEPOLIA); + + // Step 11: Enable fiat display on testnets in settings + await headerNavbar.openSettingsPage(); + await settingsPage.clickAdvancedTab(); + await settingsPage.toggleShowFiatOnTestnets(); + await settingsPage.closeSettingsPage(); + + // Step 12: Verify USD balance on Sepolia network + await homepage.check_expectedBalanceIsDisplayed( + EXPECTED_CURRENT_NETWORK_BALANCE_USD, + 'usd', + ); + }, + ); + }); +}); diff --git a/test/e2e/tests/multichain/asset-list.spec.ts b/test/e2e/tests/multichain/asset-list.spec.ts new file mode 100644 index 000000000000..5b210730ef36 --- /dev/null +++ b/test/e2e/tests/multichain/asset-list.spec.ts @@ -0,0 +1,205 @@ +import { strict as assert } from 'assert'; +import { Suite } from 'mocha'; +import { Driver } from '../../webdriver/driver'; +import { withFixtures, defaultGanacheOptions } from '../../helpers'; +import { Ganache } from '../../seeder/ganache'; +import FixtureBuilder from '../../fixture-builder'; +import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow'; +import HeaderNavbar from '../../page-objects/pages/header-navbar'; +import SelectNetwork from '../../page-objects/pages/dialog/select-network'; +import { SMART_CONTRACTS } from '../../seeder/smart-contracts'; +import SendTokenPage from '../../page-objects/pages/send/send-token-page'; +import AssetListPage from '../../page-objects/pages/asset-list'; + +const NETWORK_NAME_MAINNET = 'Ethereum Mainnet'; +const LINEA_NAME_MAINNET = 'Linea Mainnet'; +const LOCALHOST = 'Localhost 8545'; +const BALANCE_AMOUNT = '24.9956'; + +function buildFixtures(title: string) { + return { + fixtures: new FixtureBuilder() + .withPermissionControllerConnectedToTestDapp() + .withTokensControllerERC20() + .build(), + ganacheOptions: defaultGanacheOptions, + smartContract: SMART_CONTRACTS.HST, + title, + }; +} + +describe('Multichain Asset List', function (this: Suite) { + if (!process.env.PORTFOLIO_VIEW) { + return; + } + + it('persists the preferred asset list preference when changing networks', async function () { + await withFixtures( + buildFixtures(this.test?.fullTitle() as string), + async ({ + driver, + ganacheServer, + }: { + driver: Driver; + ganacheServer?: Ganache; + }) => { + await loginWithBalanceValidation(driver, ganacheServer); + const headerNavbar = new HeaderNavbar(driver); + const selectNetworkDialog = new SelectNetwork(driver); + const assetListPage = new AssetListPage(driver); + await headerNavbar.clickSwitchNetworkDropDown(); + await selectNetworkDialog.selectNetworkName(NETWORK_NAME_MAINNET); + await assetListPage.waitUntilAssetListHasItems(2); + await assetListPage.openNetworksFilter(); + await assetListPage.clickCurrentNetworkOption(); + await headerNavbar.clickSwitchNetworkDropDown(); + await selectNetworkDialog.selectNetworkName(LINEA_NAME_MAINNET); + await assetListPage.waitUntilFilterLabelIs(LINEA_NAME_MAINNET); + await assetListPage.waitUntilAssetListHasItems(1); + assert.equal( + await assetListPage.getNetworksFilterLabel(), + LINEA_NAME_MAINNET, + ); + }, + ); + }); + it('allows clicking into the asset details page of native token on another network', async function () { + await withFixtures( + buildFixtures(this.test?.fullTitle() as string), + async ({ + driver, + ganacheServer, + }: { + driver: Driver; + ganacheServer?: Ganache; + }) => { + await loginWithBalanceValidation(driver, ganacheServer); + const headerNavbar = new HeaderNavbar(driver); + const selectNetworkDialog = new SelectNetwork(driver); + const assetListPage = new AssetListPage(driver); + await headerNavbar.clickSwitchNetworkDropDown(); + await selectNetworkDialog.selectNetworkName(NETWORK_NAME_MAINNET); + await assetListPage.waitUntilAssetListHasItems(2); + await driver.clickElement('.multichain-token-list-item'); + const coinOverviewElement = await driver.findElement( + '[data-testid="coin-overview-buy"]', + ); + const multichainTokenListButton = await driver.findElement( + '[data-testid="multichain-token-list-button"]', + ); + assert.ok(coinOverviewElement, 'coin-overview-buy is present'); + assert.ok( + multichainTokenListButton, + 'multichain-token-list-button is present', + ); + }, + ); + }); + it('switches networks when clicking on send for a token on another network', async function () { + await withFixtures( + buildFixtures(this.test?.fullTitle() as string), + async ({ + driver, + ganacheServer, + }: { + driver: Driver; + ganacheServer?: Ganache; + }) => { + await loginWithBalanceValidation(driver, ganacheServer); + const headerNavbar = new HeaderNavbar(driver); + const selectNetworkDialog = new SelectNetwork(driver); + const assetListPage = new AssetListPage(driver); + await headerNavbar.clickSwitchNetworkDropDown(); + await selectNetworkDialog.selectNetworkName(NETWORK_NAME_MAINNET); + const sendPage = new SendTokenPage(driver); + await assetListPage.waitUntilAssetListHasItems(2); + await assetListPage.clickOnAsset('TST'); + await driver.clickElement('[data-testid="eth-overview-send"]'); + await sendPage.check_networkChange(LOCALHOST); + await sendPage.check_pageIsLoaded(); + await sendPage.fillRecipient( + '0x2f318C334780961FB129D2a6c30D0763d9a5C970', + ); + await sendPage.clickAssetPickerButton(); + const assetPickerItems = await sendPage.getAssetPickerItems(); + assert.equal( + assetPickerItems.length, + 2, + 'Two assets should be shown in the asset picker', + ); + }, + ); + }); + it('switches networks when clicking on swap for a token on another network', async function () { + await withFixtures( + buildFixtures(this.test?.fullTitle() as string), + async ({ + driver, + ganacheServer, + }: { + driver: Driver; + ganacheServer?: Ganache; + }) => { + await loginWithBalanceValidation(driver, ganacheServer); + const headerNavbar = new HeaderNavbar(driver); + const selectNetworkDialog = new SelectNetwork(driver); + const assetListPage = new AssetListPage(driver); + await headerNavbar.clickSwitchNetworkDropDown(); + await selectNetworkDialog.selectNetworkName(NETWORK_NAME_MAINNET); + await assetListPage.waitUntilAssetListHasItems(2); + await assetListPage.clickOnAsset('TST'); + await driver.clickElement('.mm-box > button:nth-of-type(3)'); + const toastTextElement = await driver.findElement('.toast-text'); + const toastText = await toastTextElement.getText(); + assert.equal( + toastText, + `You're now using ${LOCALHOST}`, + 'Toast text is correct', + ); + }, + ); + }); + it('shows correct asset and balance when swapping on a different chain', async function () { + await withFixtures( + buildFixtures(this.test?.fullTitle() as string), + async ({ + driver, + ganacheServer, + }: { + driver: Driver; + ganacheServer?: Ganache; + }) => { + await loginWithBalanceValidation(driver, ganacheServer); + const headerNavbar = new HeaderNavbar(driver); + const assetListPage = new AssetListPage(driver); + const selectNetworkDialog = new SelectNetwork(driver); + await headerNavbar.clickSwitchNetworkDropDown(); + await selectNetworkDialog.selectNetworkName(LINEA_NAME_MAINNET); + await assetListPage.waitUntilAssetListHasItems(2); + + await assetListPage.clickOnAsset('Ethereum'); + + const swapButton = await driver.findElement( + '[data-testid="token-overview-button-swap"]', + ); + await swapButton.click(); + const toastTextElement = await driver.findElement('.toast-text'); + const toastText = await toastTextElement.getText(); + assert.equal( + toastText, + `You're now using ${LOCALHOST}`, + 'Toast text is correct', + ); + const balanceMessageElement = await driver.findElement( + '.prepare-swap-page__balance-message', + ); + const balanceMessage = await balanceMessageElement.getText(); + assert.equal( + balanceMessage.replace('Max', '').trim(), + `Balance: ${BALANCE_AMOUNT}`, + 'Balance message is correct', + ); + }, + ); + }); +}); diff --git a/test/e2e/webdriver/driver.js b/test/e2e/webdriver/driver.js index 42fa0f018f6d..b0a335eb0d64 100644 --- a/test/e2e/webdriver/driver.js +++ b/test/e2e/webdriver/driver.js @@ -767,6 +767,29 @@ class Driver { ); } + /** + * Waits for a condition to be met within a given timeout period. + * + * @param {Function} condition - The condition to wait for. This function should return a boolean indicating whether the condition is met. + * @param {object} options - Options for the wait. + * @param {number} options.timeout - The maximum amount of time (in milliseconds) to wait for the condition to be met. + * @param {number} options.interval - The interval (in milliseconds) between checks for the condition. + * @returns {Promise} A promise that resolves when the condition is met or the timeout is reached. + * @throws {Error} Throws an error if the condition is not met within the timeout period. + */ + async waitUntil(condition, options) { + const { timeout, interval } = options; + const endTime = Date.now() + timeout; + + while (Date.now() < endTime) { + if (await condition()) { + return true; + } + await new Promise((resolve) => setTimeout(resolve, interval)); + } + throw new Error('Condition not met within timeout'); + } + /** * Checks if an element that matches the given locator is present on the page. * diff --git a/ui/pages/bridge/index.test.tsx b/ui/pages/bridge/index.test.tsx index 7d5f813513c5..1dc898d71685 100644 --- a/ui/pages/bridge/index.test.tsx +++ b/ui/pages/bridge/index.test.tsx @@ -16,9 +16,7 @@ setBackgroundConnection({ setSwapsLiveness: jest.fn(() => true), setSwapsTokens: jest.fn(), setSwapsTxGasPrice: jest.fn(), - gasFeeStartPollingByNetworkClientId: jest - .fn() - .mockResolvedValue('pollingToken'), + gasFeeStartPolling: jest.fn().mockResolvedValue('pollingToken'), gasFeeStopPollingByPollingToken: jest.fn(), getNetworkConfigurationByNetworkClientId: jest .fn() diff --git a/ui/pages/bridge/quotes/index.scss b/ui/pages/bridge/quotes/index.scss index 6407309220c2..0d9eafa9ad69 100644 --- a/ui/pages/bridge/quotes/index.scss +++ b/ui/pages/bridge/quotes/index.scss @@ -63,7 +63,9 @@ } } -.mm-modal-content__dialog { - display: flex; - height: 100%; +.quotes-modal { + .mm-modal-content__dialog { + display: flex; + height: 100%; + } } diff --git a/ui/pages/confirmations/confirm-send-ether/confirm-send-ether.test.js b/ui/pages/confirmations/confirm-send-ether/confirm-send-ether.test.js index 04caf63d12e0..e30dd925c4d3 100644 --- a/ui/pages/confirmations/confirm-send-ether/confirm-send-ether.test.js +++ b/ui/pages/confirmations/confirm-send-ether/confirm-send-ether.test.js @@ -10,9 +10,7 @@ import ConfirmSendEther from './confirm-send-ether'; jest.mock('../components/simulation-details/useSimulationMetrics'); setBackgroundConnection({ - gasFeeStartPollingByNetworkClientId: jest - .fn() - .mockResolvedValue('pollingToken'), + gasFeeStartPolling: jest.fn().mockResolvedValue('pollingToken'), gasFeeStopPollingByPollingToken: jest.fn(), getNetworkConfigurationByNetworkClientId: jest.fn().mockImplementation(() => Promise.resolve({ diff --git a/ui/pages/confirmations/confirm-transaction-base/confirm-transaction-base.test.js b/ui/pages/confirmations/confirm-transaction-base/confirm-transaction-base.test.js index 5a846874fed3..56be8fd5aee3 100644 --- a/ui/pages/confirmations/confirm-transaction-base/confirm-transaction-base.test.js +++ b/ui/pages/confirmations/confirm-transaction-base/confirm-transaction-base.test.js @@ -31,9 +31,7 @@ jest.mock('../components/simulation-details/useSimulationMetrics'); const middleware = [thunk]; setBackgroundConnection({ - gasFeeStartPollingByNetworkClientId: jest - .fn() - .mockResolvedValue('pollingToken'), + gasFeeStartPolling: jest.fn().mockResolvedValue('pollingToken'), gasFeeStopPollingByPollingToken: jest.fn(), getNetworkConfigurationByNetworkClientId: jest.fn().mockImplementation(() => Promise.resolve({ diff --git a/ui/pages/confirmations/confirm-transaction/confirm-transaction.transaction.test.js b/ui/pages/confirmations/confirm-transaction/confirm-transaction.transaction.test.js index 09eb13c16919..a7db429a90e8 100644 --- a/ui/pages/confirmations/confirm-transaction/confirm-transaction.transaction.test.js +++ b/ui/pages/confirmations/confirm-transaction/confirm-transaction.transaction.test.js @@ -19,7 +19,7 @@ const middleware = [thunk]; setBackgroundConnection({ getGasFeeTimeEstimate: jest.fn(), - gasFeeStartPollingByNetworkClientId: jest.fn(), + gasFeeStartPolling: jest.fn(), gasFeeStopPollingByPollingToken: jest.fn(), promisifiedBackground: jest.fn(), tryReverseResolveAddress: jest.fn(), diff --git a/ui/pages/swaps/index.test.js b/ui/pages/swaps/index.test.js index 4157b614562f..e9e16d91b208 100644 --- a/ui/pages/swaps/index.test.js +++ b/ui/pages/swaps/index.test.js @@ -33,9 +33,7 @@ setBackgroundConnection({ setSwapsLiveness: jest.fn(() => true), setSwapsTokens: jest.fn(), setSwapsTxGasPrice: jest.fn(), - gasFeeStartPollingByNetworkClientId: jest - .fn() - .mockResolvedValue('pollingToken'), + gasFeeStartPolling: jest.fn().mockResolvedValue('pollingToken'), gasFeeStopPollingByPollingToken: jest.fn(), getNetworkConfigurationByNetworkClientId: jest .fn() diff --git a/ui/store/actions.ts b/ui/store/actions.ts index f3f4e712acf5..90018c4d7389 100644 --- a/ui/store/actions.ts +++ b/ui/store/actions.ts @@ -4728,10 +4728,9 @@ export async function accountTrackerStopPollingByPollingToken( export async function gasFeeStartPollingByNetworkClientId( networkClientId: string, ) { - const pollingToken = await submitRequestToBackground( - 'gasFeeStartPollingByNetworkClientId', - [networkClientId], - ); + const pollingToken = await submitRequestToBackground('gasFeeStartPolling', [ + { networkClientId }, + ]); await addPollingTokenToAppState(pollingToken); return pollingToken; } diff --git a/yarn.lock b/yarn.lock index 968594154f06..88e84e6d37b1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5695,6 +5695,26 @@ __metadata: languageName: node linkType: hard +"@metamask/gas-fee-controller@npm:^21.0.0": + version: 21.0.0 + resolution: "@metamask/gas-fee-controller@npm:21.0.0" + dependencies: + "@metamask/base-controller": "npm:^7.0.1" + "@metamask/controller-utils": "npm:^11.3.0" + "@metamask/eth-query": "npm:^4.0.0" + "@metamask/ethjs-unit": "npm:^0.3.0" + "@metamask/polling-controller": "npm:^11.0.0" + "@metamask/utils": "npm:^9.1.0" + "@types/bn.js": "npm:^5.1.5" + "@types/uuid": "npm:^8.3.0" + bn.js: "npm:^5.2.1" + uuid: "npm:^8.3.2" + peerDependencies: + "@metamask/network-controller": ^21.0.0 + checksum: 10/8b41c7257f7dc17deb3f550cfdde0288da142d11536bb55c998bec8267fa62243e36fb6468a44224cd90ed2f49ba3ba1dbe93c2b0834a725752c5a66ae283303 + languageName: node + linkType: hard + "@metamask/jazzicon@npm:^2.0.0": version: 2.0.0 resolution: "@metamask/jazzicon@npm:2.0.0" @@ -6107,25 +6127,6 @@ __metadata: languageName: node linkType: hard -"@metamask/permission-controller@npm:^10.0.0": - version: 10.0.0 - resolution: "@metamask/permission-controller@npm:10.0.0" - dependencies: - "@metamask/base-controller": "npm:^6.0.0" - "@metamask/controller-utils": "npm:^11.0.0" - "@metamask/json-rpc-engine": "npm:^9.0.0" - "@metamask/rpc-errors": "npm:^6.2.1" - "@metamask/utils": "npm:^8.3.0" - "@types/deep-freeze-strict": "npm:^1.1.0" - deep-freeze-strict: "npm:^1.1.1" - immer: "npm:^9.0.6" - nanoid: "npm:^3.1.31" - peerDependencies: - "@metamask/approval-controller": ^7.0.0 - checksum: 10/0c72e205be760fc471b2a6892a9ad52d5c6a40b4cf1757464e992a5ada2dec57efbb24b09351ce8c29990b59f1d731cd2b338caaef37ce7690ea2d1919afe061 - languageName: node - linkType: hard - "@metamask/permission-controller@npm:^11.0.0, @metamask/permission-controller@npm:^11.0.3": version: 11.0.3 resolution: "@metamask/permission-controller@npm:11.0.3" @@ -6202,6 +6203,22 @@ __metadata: languageName: node linkType: hard +"@metamask/polling-controller@npm:^11.0.0": + version: 11.0.0 + resolution: "@metamask/polling-controller@npm:11.0.0" + dependencies: + "@metamask/base-controller": "npm:^7.0.1" + "@metamask/controller-utils": "npm:^11.3.0" + "@metamask/utils": "npm:^9.1.0" + "@types/uuid": "npm:^8.3.0" + fast-json-stable-stringify: "npm:^2.1.0" + uuid: "npm:^8.3.2" + peerDependencies: + "@metamask/network-controller": ^21.0.0 + checksum: 10/67b563a5d1ce02dc9c2db25ad4ad1fb9f75d5578cf380cce85176ff2cd136addce612c3982653254647b9d8c535374e93d96abb6e500e42076bf3a524a72e75f + languageName: node + linkType: hard + "@metamask/polling-controller@npm:^12.0.1": version: 12.0.1 resolution: "@metamask/polling-controller@npm:12.0.1" @@ -6771,33 +6788,28 @@ __metadata: languageName: node linkType: hard -"@metamask/user-operation-controller@npm:^13.0.0": - version: 13.0.0 - resolution: "@metamask/user-operation-controller@npm:13.0.0" +"@metamask/user-operation-controller@npm:^16.0.0": + version: 16.0.0 + resolution: "@metamask/user-operation-controller@npm:16.0.0" dependencies: - "@metamask/approval-controller": "npm:^7.0.0" - "@metamask/base-controller": "npm:^6.0.0" - "@metamask/controller-utils": "npm:^11.0.0" + "@metamask/base-controller": "npm:^7.0.1" + "@metamask/controller-utils": "npm:^11.3.0" "@metamask/eth-query": "npm:^4.0.0" - "@metamask/gas-fee-controller": "npm:^18.0.0" - "@metamask/keyring-controller": "npm:^17.1.0" - "@metamask/network-controller": "npm:^19.0.0" - "@metamask/polling-controller": "npm:^8.0.0" - "@metamask/rpc-errors": "npm:^6.2.1" - "@metamask/transaction-controller": "npm:^34.0.0" - "@metamask/utils": "npm:^8.3.0" + "@metamask/polling-controller": "npm:^11.0.0" + "@metamask/rpc-errors": "npm:^7.0.0" + "@metamask/superstruct": "npm:^3.1.0" + "@metamask/utils": "npm:^9.1.0" bn.js: "npm:^5.2.1" immer: "npm:^9.0.6" lodash: "npm:^4.17.21" - superstruct: "npm:^1.0.3" uuid: "npm:^8.3.2" peerDependencies: "@metamask/approval-controller": ^7.0.0 - "@metamask/gas-fee-controller": ^18.0.0 + "@metamask/gas-fee-controller": ^21.0.0 "@metamask/keyring-controller": ^17.0.0 - "@metamask/network-controller": ^19.0.0 - "@metamask/transaction-controller": ^34.0.0 - checksum: 10/600dd845dfc30ff852d766bd012ce40b4a6fb2276538d358cbe3ef1ce5815e4dba8f94e4911b7cb0506857133b185923b43af73ec39c7628eb86eedfdaf8dc59 + "@metamask/network-controller": ^21.0.0 + "@metamask/transaction-controller": ^37.0.0 + checksum: 10/36ef43910f9e94ae7823902113acdaf7d4031423930f0a35fe4dd3b948a00e8088ea590354afbdb507b32712761720727f0ee905ad6d3db83ef3f0f145b8452d languageName: node linkType: hard @@ -26847,7 +26859,7 @@ __metadata: "@metamask/ethjs-contract": "npm:^0.4.1" "@metamask/ethjs-query": "npm:^0.7.1" "@metamask/forwarder": "npm:^1.1.0" - "@metamask/gas-fee-controller": "npm:^18.0.0" + "@metamask/gas-fee-controller": "npm:^21.0.0" "@metamask/jazzicon": "npm:^2.0.0" "@metamask/json-rpc-engine": "npm:^10.0.0" "@metamask/json-rpc-middleware-stream": "npm:^8.0.4" @@ -26864,7 +26876,7 @@ __metadata: "@metamask/notification-services-controller": "npm:^0.14.0" "@metamask/object-multiplex": "npm:^2.0.0" "@metamask/obs-store": "npm:^9.0.0" - "@metamask/permission-controller": "npm:^10.0.0" + "@metamask/permission-controller": "npm:^11.0.0" "@metamask/permission-log-controller": "npm:^2.0.1" "@metamask/phishing-controller": "npm:^12.3.0" "@metamask/phishing-warning": "npm:^4.1.0" @@ -26892,7 +26904,7 @@ __metadata: "@metamask/test-bundler": "npm:^1.0.0" "@metamask/test-dapp": "npm:8.13.0" "@metamask/transaction-controller": "npm:^40.1.0" - "@metamask/user-operation-controller": "npm:^13.0.0" + "@metamask/user-operation-controller": "npm:^16.0.0" "@metamask/utils": "npm:^10.0.1" "@ngraveio/bc-ur": "npm:^1.1.12" "@noble/hashes": "npm:^1.3.3"