From e2c1f688970aec7ad52e9e7f309b6b38ace178ca Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 15 Jul 2024 17:18:20 -0500 Subject: [PATCH] fix tests + lint --- .../lib/multichain-api/caip25permissions.ts | 2 -- .../lib/multichain-api/scope/assert.test.ts | 5 ----- app/scripts/lib/multichain-api/scope/assert.ts | 1 - .../createMethodMiddleware.test.js | 14 ++++++++++---- app/scripts/metamask-controller.test.js | 7 +++++-- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/app/scripts/lib/multichain-api/caip25permissions.ts b/app/scripts/lib/multichain-api/caip25permissions.ts index 3e7258d6b740..5cc1e75b664a 100644 --- a/app/scripts/lib/multichain-api/caip25permissions.ts +++ b/app/scripts/lib/multichain-api/caip25permissions.ts @@ -18,7 +18,6 @@ import { type NonEmptyArray, } from '@metamask/utils'; import { NetworkClientId } from '@metamask/network-controller'; -import { InternalAccount } from '@metamask/keyring-api'; import { cloneDeep, isEqual } from 'lodash'; import { Scope, @@ -58,7 +57,6 @@ type Caip25EndowmentSpecification = ValidPermissionSpecification<{ * * @param builderOptions - The specification builder options. * @param builderOptions.findNetworkClientIdByChainId - * @param builderOptions.getInternalAccounts * @returns The specification for the `caip25` endowment. */ const specificationBuilder: PermissionSpecificationBuilder< diff --git a/app/scripts/lib/multichain-api/scope/assert.test.ts b/app/scripts/lib/multichain-api/scope/assert.test.ts index 36be0014e63c..f14af05038c8 100644 --- a/app/scripts/lib/multichain-api/scope/assert.test.ts +++ b/app/scripts/lib/multichain-api/scope/assert.test.ts @@ -22,8 +22,6 @@ describe('Scope Assert', () => { describe('assertScopeSupported', () => { const findNetworkClientIdByChainId = jest.fn(); - const getInternalAccounts = jest.fn(); - describe('scopeString', () => { it('checks if the scopeString is supported', () => { try { @@ -66,7 +64,6 @@ describe('Scope Assert', () => { }, { findNetworkClientIdByChainId, - getInternalAccounts, }, ); }).toThrow( @@ -139,8 +136,6 @@ describe('Scope Assert', () => { describe('assertScopesSupported', () => { const findNetworkClientIdByChainId = jest.fn(); - const getInternalAccounts = jest.fn(); - it('throws an error if no scopes are defined', () => { expect(() => { assertScopesSupported( diff --git a/app/scripts/lib/multichain-api/scope/assert.ts b/app/scripts/lib/multichain-api/scope/assert.ts index a10be6fb3073..716d5146ad9f 100644 --- a/app/scripts/lib/multichain-api/scope/assert.ts +++ b/app/scripts/lib/multichain-api/scope/assert.ts @@ -55,7 +55,6 @@ export const assertScopeSupported = ( 'Requested notifications are not supported', ); } - }; export const assertScopesSupported = ( diff --git a/app/scripts/lib/rpc-method-middleware/createMethodMiddleware.test.js b/app/scripts/lib/rpc-method-middleware/createMethodMiddleware.test.js index 46aba9abe746..d658004eeea6 100644 --- a/app/scripts/lib/rpc-method-middleware/createMethodMiddleware.test.js +++ b/app/scripts/lib/rpc-method-middleware/createMethodMiddleware.test.js @@ -3,7 +3,11 @@ import { assertIsJsonRpcFailure, assertIsJsonRpcSuccess, } from '@metamask/utils'; -import { createMethodMiddleware, createLegacyMethodMiddleware } from '.'; +import { + createEip1193MethodMiddleware, + createEthAccountsMethodMiddleware, + createMultichainMethodMiddleware, +} from '.'; jest.mock('@metamask/permission-controller', () => ({ permissionRpcMethods: { handlers: [] }, @@ -39,13 +43,15 @@ jest.mock('./handlers', () => { return { handlers: [getHandler()], - legacyHandlers: [getHandler()], + eip1193OnlyHandlers: [getHandler()], + ethAccountsHandler: getHandler(), }; }); describe.each([ - ['createMethodMiddleware', createMethodMiddleware], - ['createLegacyMethodMiddleware', createLegacyMethodMiddleware], + ['createEip1193MethodMiddleware', createEip1193MethodMiddleware], + ['createEthAccountsMethodMiddleware', createEthAccountsMethodMiddleware], + ['createMultichainMethodMiddleware', createMultichainMethodMiddleware], ])('%s', (_name, createMiddleware) => { const method1 = 'method1'; diff --git a/app/scripts/metamask-controller.test.js b/app/scripts/metamask-controller.test.js index 84d836048b23..d90d082c418f 100644 --- a/app/scripts/metamask-controller.test.js +++ b/app/scripts/metamask-controller.test.js @@ -101,10 +101,13 @@ const createLoggerMiddlewareMock = () => (req, res, next) => { jest.mock('./lib/createLoggerMiddleware', () => createLoggerMiddlewareMock); const rpcMethodMiddlewareMock = { - createMethodMiddleware: () => (_req, _res, next, _end) => { + createEip1193MethodMiddleware: () => (_req, _res, next, _end) => { next(); }, - createLegacyMethodMiddleware: () => (_req, _res, next, _end) => { + createEthAccountsMethodMiddleware: () => (_req, _res, next, _end) => { + next(); + }, + createMultichainMethodMiddleware: () => (_req, _res, next, _end) => { next(); }, createUnsupportedMethodMiddleware: () => (_req, _res, next, _end) => {