From a53cee562f69c6be656b2167803f20f6b9483e8c Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Wed, 6 Mar 2024 01:06:03 +0000 Subject: [PATCH 01/16] deps: json-rpc-engine@^6.1.0 -> @metamask/json-rpc-engine@^7.3.3 --- ...ToNonEvmAccountReqFilterMiddleware.test.ts | 2 +- ...thodsToNonEvmAccountReqFilterMiddleware.ts | 2 +- app/scripts/lib/createMetamaskMiddleware.js | 5 +++- app/scripts/lib/middleware/pending.js | 2 +- .../createMethodMiddleware.js | 2 +- .../createMethodMiddleware.test.js | 2 +- .../createUnsupportedMethodMiddleware.ts | 2 +- .../handlers/eth-accounts.ts | 2 +- .../handlers/get-provider-state.test.ts | 2 +- .../handlers/get-provider-state.ts | 2 +- .../institutional/mmi-authenticate.js | 4 ++-- .../mmi-check-if-token-is-present.js | 4 ++-- .../mmi-open-add-hardware-wallet.js | 4 ++-- .../handlers/institutional/mmi-portfolio.js | 4 ++-- .../mmi-set-account-and-network.js | 4 ++-- .../handlers/institutional/mmi-supported.js | 4 ++-- .../handlers/log-web3-shim-usage.test.ts | 2 +- .../handlers/log-web3-shim-usage.ts | 2 +- .../handlers/request-accounts.js | 4 ++-- .../handlers/send-metadata.js | 4 ++-- .../handlers/watch-asset.js | 4 ++-- .../tx-verification-middleware.ts | 4 ++-- app/scripts/metamask-controller.js | 2 +- package.json | 2 +- test/stub/provider.js | 5 +++- yarn.lock | 23 ++----------------- 26 files changed, 43 insertions(+), 56 deletions(-) diff --git a/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.test.ts b/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.test.ts index a5e04f6b7834..b6160a1d7a88 100644 --- a/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.test.ts +++ b/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.test.ts @@ -1,6 +1,6 @@ import { jsonrpc2 } from '@metamask/utils'; import { BtcAccountType, EthAccountType } from '@metamask/keyring-api'; -import { Json } from 'json-rpc-engine'; +import { Json } from '@metamask/json-rpc-engine'; import createEvmMethodsToNonEvmAccountReqFilterMiddleware, { EvmMethodsToNonEvmAccountFilterMessenger, } from './createEvmMethodsToNonEvmAccountReqFilterMiddleware'; diff --git a/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.ts b/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.ts index 3e1eca86997e..89edd402d97c 100644 --- a/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.ts +++ b/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.ts @@ -1,7 +1,7 @@ import { isEvmAccountType } from '@metamask/keyring-api'; import { RestrictedControllerMessenger } from '@metamask/base-controller'; import { AccountsControllerGetSelectedAccountAction } from '@metamask/accounts-controller'; -import { JsonRpcMiddleware } from 'json-rpc-engine'; +import { JsonRpcMiddleware } from '@metamask/json-rpc-engine'; import { RestrictedEthMethods } from '../../../shared/constants/permissions'; import { unrestrictedEthSigningMethods } from '../controllers/permissions'; diff --git a/app/scripts/lib/createMetamaskMiddleware.js b/app/scripts/lib/createMetamaskMiddleware.js index d48ae32dc4a3..9ea07b0d28e5 100644 --- a/app/scripts/lib/createMetamaskMiddleware.js +++ b/app/scripts/lib/createMetamaskMiddleware.js @@ -1,4 +1,7 @@ -import { createScaffoldMiddleware, mergeMiddleware } from 'json-rpc-engine'; +import { + createScaffoldMiddleware, + mergeMiddleware, +} from '@metamask/json-rpc-engine'; import { createWalletMiddleware } from '@metamask/eth-json-rpc-middleware'; import { createPendingNonceMiddleware, diff --git a/app/scripts/lib/middleware/pending.js b/app/scripts/lib/middleware/pending.js index 9e01d11ffcb2..0c9d3445a01e 100644 --- a/app/scripts/lib/middleware/pending.js +++ b/app/scripts/lib/middleware/pending.js @@ -1,4 +1,4 @@ -import { createAsyncMiddleware } from 'json-rpc-engine'; +import { createAsyncMiddleware } from '@metamask/json-rpc-engine'; import { formatTxMetaForRpcResult } from '../util'; export function createPendingNonceMiddleware({ getPendingNonce }) { diff --git a/app/scripts/lib/rpc-method-middleware/createMethodMiddleware.js b/app/scripts/lib/rpc-method-middleware/createMethodMiddleware.js index cee4e7763255..bbc06e7033f5 100644 --- a/app/scripts/lib/rpc-method-middleware/createMethodMiddleware.js +++ b/app/scripts/lib/rpc-method-middleware/createMethodMiddleware.js @@ -42,7 +42,7 @@ function makeMethodMiddlewareMaker(handlers) { * * @param {Record unknown | Promise>} hooks - Required "hooks" into our * controllers. - * @returns {import('json-rpc-engine').JsonRpcMiddleware} The method middleware function. + * @returns {import('@metamask/json-rpc-engine').JsonRpcMiddleware} The method middleware function. */ const makeMethodMiddleware = (hooks) => { assertExpectedHook(hooks, expectedHookNames); diff --git a/app/scripts/lib/rpc-method-middleware/createMethodMiddleware.test.js b/app/scripts/lib/rpc-method-middleware/createMethodMiddleware.test.js index 46aba9abe746..c91d0d0dc02c 100644 --- a/app/scripts/lib/rpc-method-middleware/createMethodMiddleware.test.js +++ b/app/scripts/lib/rpc-method-middleware/createMethodMiddleware.test.js @@ -1,4 +1,4 @@ -import { JsonRpcEngine } from 'json-rpc-engine'; +import { JsonRpcEngine } from '@metamask/json-rpc-engine'; import { assertIsJsonRpcFailure, assertIsJsonRpcSuccess, diff --git a/app/scripts/lib/rpc-method-middleware/createUnsupportedMethodMiddleware.ts b/app/scripts/lib/rpc-method-middleware/createUnsupportedMethodMiddleware.ts index 12abc82d4b21..ac8c48c6df9d 100644 --- a/app/scripts/lib/rpc-method-middleware/createUnsupportedMethodMiddleware.ts +++ b/app/scripts/lib/rpc-method-middleware/createUnsupportedMethodMiddleware.ts @@ -1,5 +1,5 @@ +import type { JsonRpcMiddleware } from '@metamask/json-rpc-engine'; import { rpcErrors } from '@metamask/rpc-errors'; -import type { JsonRpcMiddleware } from 'json-rpc-engine'; import { UNSUPPORTED_RPC_METHODS } from '../../../../shared/constants/network'; /** diff --git a/app/scripts/lib/rpc-method-middleware/handlers/eth-accounts.ts b/app/scripts/lib/rpc-method-middleware/handlers/eth-accounts.ts index 003cbd88281b..47c2f0c2e318 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/eth-accounts.ts +++ b/app/scripts/lib/rpc-method-middleware/handlers/eth-accounts.ts @@ -1,7 +1,7 @@ import type { JsonRpcEngineEndCallback, JsonRpcEngineNextCallback, -} from 'json-rpc-engine'; +} from '@metamask/json-rpc-engine'; import type { JsonRpcRequest, JsonRpcParams, diff --git a/app/scripts/lib/rpc-method-middleware/handlers/get-provider-state.test.ts b/app/scripts/lib/rpc-method-middleware/handlers/get-provider-state.test.ts index f3d76a09f5fc..078bd7866a31 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/get-provider-state.test.ts +++ b/app/scripts/lib/rpc-method-middleware/handlers/get-provider-state.test.ts @@ -1,5 +1,5 @@ import { PendingJsonRpcResponse } from '@metamask/utils'; -import { JsonRpcEngineEndCallback } from 'json-rpc-engine'; +import { JsonRpcEngineEndCallback } from '@metamask/json-rpc-engine'; import getProviderState, { GetProviderState, ProviderStateHandlerResult, diff --git a/app/scripts/lib/rpc-method-middleware/handlers/get-provider-state.ts b/app/scripts/lib/rpc-method-middleware/handlers/get-provider-state.ts index c95b66e1a20d..514f8af6dfa7 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/get-provider-state.ts +++ b/app/scripts/lib/rpc-method-middleware/handlers/get-provider-state.ts @@ -1,7 +1,7 @@ import type { JsonRpcEngineNextCallback, JsonRpcEngineEndCallback, -} from 'json-rpc-engine'; +} from '@metamask/json-rpc-engine'; import type { PendingJsonRpcResponse, JsonRpcParams, diff --git a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-authenticate.js b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-authenticate.js index 48014a6d66fa..57d9e8e53c52 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-authenticate.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-authenticate.js @@ -21,8 +21,8 @@ export default mmiAuthenticate; */ /** - * @param {import('json-rpc-engine').JsonRpcRequest} req - The JSON-RPC request object. - * @param {import('json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. + * @param {import('@metamask/json-rpc-engine').JsonRpcRequest} req - The JSON-RPC request object. + * @param {import('@metamask/json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. * @param {Function} _next - The json-rpc-engine 'next' callback. * @param {Function} end - The json-rpc-engine 'end' callback. * @param {WatchAssetOptions} options diff --git a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-check-if-token-is-present.js b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-check-if-token-is-present.js index 1e05251a25c4..f45772d6ad7d 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-check-if-token-is-present.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-check-if-token-is-present.js @@ -23,8 +23,8 @@ export default mmiAuthenticate; */ /** - * @param {import('json-rpc-engine').JsonRpcRequest} req - The JSON-RPC request object. - * @param {import('json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. + * @param {import('@metamask/json-rpc-engine').JsonRpcRequest} req - The JSON-RPC request object. + * @param {import('@metamask/json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. * @param {Function} _next - The json-rpc-engine 'next' callback. * @param {Function} end - The json-rpc-engine 'end' callback. * @param options0 diff --git a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-open-add-hardware-wallet.js b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-open-add-hardware-wallet.js index 61af6eb43fe8..b70d13a88f2f 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-open-add-hardware-wallet.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-open-add-hardware-wallet.js @@ -16,8 +16,8 @@ export default mmiOpenAddHardwareWallet; */ /** - * @param {import('json-rpc-engine').JsonRpcRequest} req - The JSON-RPC request object. - * @param {import('json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. + * @param {import('@metamask/json-rpc-engine').JsonRpcRequest} req - The JSON-RPC request object. + * @param {import('@metamask/json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. * @param {Function} _next - The json-rpc-engine 'next' callback. * @param {Function} end - The json-rpc-engine 'end' callback. * @param {WatchAssetOptions} options diff --git a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-portfolio.js b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-portfolio.js index cbe96127682f..e637ad419244 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-portfolio.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-portfolio.js @@ -22,8 +22,8 @@ export default mmiPortfolio; */ /** - * @param {import('json-rpc-engine').JsonRpcRequest} req - The JSON-RPC request object. - * @param {import('json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. + * @param {import('@metamask/json-rpc-engine').JsonRpcRequest} req - The JSON-RPC request object. + * @param {import('@metamask/json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. * @param {Function} _next - The json-rpc-engine 'next' callback. * @param {Function} end - The json-rpc-engine 'end' callback. * @param {WatchAssetOptions} options diff --git a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-set-account-and-network.js b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-set-account-and-network.js index 6c3dc41da9d2..36e4add51cdf 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-set-account-and-network.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-set-account-and-network.js @@ -23,8 +23,8 @@ export default mmiSetAccountAndNetwork; */ /** - * @param {import('json-rpc-engine').JsonRpcRequest} req - The JSON-RPC request object. - * @param {import('json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. + * @param {import('@metamask/json-rpc-engine').JsonRpcRequest} req - The JSON-RPC request object. + * @param {import('@metamask/json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. * @param {Function} _next - The json-rpc-engine 'next' callback. * @param {Function} end - The json-rpc-engine 'end' callback. * @param {WatchAssetOptions} options diff --git a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-supported.js b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-supported.js index 5aa987ed880f..a0d87cd7341d 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-supported.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-supported.js @@ -19,8 +19,8 @@ export default mmiSupported; */ /** - * @param {import('json-rpc-engine').JsonRpcRequest} _req - The JSON-RPC request object. - * @param {import('json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. + * @param {import('@metamask/json-rpc-engine').JsonRpcRequest} _req - The JSON-RPC request object. + * @param {import('@metamask/json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. * @param {Function} _next - The json-rpc-engine 'next' callback. * @param {Function} end - The json-rpc-engine 'end' callback. */ diff --git a/app/scripts/lib/rpc-method-middleware/handlers/log-web3-shim-usage.test.ts b/app/scripts/lib/rpc-method-middleware/handlers/log-web3-shim-usage.test.ts index d81427af8c26..1b48b75b5e4d 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/log-web3-shim-usage.test.ts +++ b/app/scripts/lib/rpc-method-middleware/handlers/log-web3-shim-usage.test.ts @@ -1,4 +1,4 @@ -import type { JsonRpcEngineEndCallback } from 'json-rpc-engine'; +import type { JsonRpcEngineEndCallback } from '@metamask/json-rpc-engine'; import { PendingJsonRpcResponse } from '@metamask/utils'; import { MESSAGE_TYPE } from '../../../../../shared/constants/app'; import { HandlerRequestType as LogWeb3ShimUsageHandlerRequest } from './types'; diff --git a/app/scripts/lib/rpc-method-middleware/handlers/log-web3-shim-usage.ts b/app/scripts/lib/rpc-method-middleware/handlers/log-web3-shim-usage.ts index bff4215ea5aa..c91bd4fa4650 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/log-web3-shim-usage.ts +++ b/app/scripts/lib/rpc-method-middleware/handlers/log-web3-shim-usage.ts @@ -1,7 +1,7 @@ import type { JsonRpcEngineNextCallback, JsonRpcEngineEndCallback, -} from 'json-rpc-engine'; +} from '@metamask/json-rpc-engine'; import type { JsonRpcParams, PendingJsonRpcResponse } from '@metamask/utils'; import { MESSAGE_TYPE } from '../../../../../shared/constants/app'; import { diff --git a/app/scripts/lib/rpc-method-middleware/handlers/request-accounts.js b/app/scripts/lib/rpc-method-middleware/handlers/request-accounts.js index 04977fe465d9..d5f6d110568d 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/request-accounts.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/request-accounts.js @@ -48,8 +48,8 @@ const locks = new Set(); /** * - * @param {import('json-rpc-engine').JsonRpcRequest} _req - The JSON-RPC request object. - * @param {import('json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. + * @param {import('@metamask/json-rpc-engine').JsonRpcRequest} _req - The JSON-RPC request object. + * @param {import('@metamask/json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. * @param {Function} _next - The json-rpc-engine 'next' callback. * @param {Function} end - The json-rpc-engine 'end' callback. * @param {RequestEthereumAccountsOptions} options - The RPC method hooks. diff --git a/app/scripts/lib/rpc-method-middleware/handlers/send-metadata.js b/app/scripts/lib/rpc-method-middleware/handlers/send-metadata.js index 35ec117a1f63..03253f6dc7b0 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/send-metadata.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/send-metadata.js @@ -25,8 +25,8 @@ export default sendMetadata; */ /** - * @param {import('json-rpc-engine').JsonRpcRequest} req - The JSON-RPC request object. - * @param {import('json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. + * @param {import('@metamask/json-rpc-engine').JsonRpcRequest} req - The JSON-RPC request object. + * @param {import('@metamask/json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. * @param {Function} _next - The json-rpc-engine 'next' callback. * @param {Function} end - The json-rpc-engine 'end' callback. * @param {SendMetadataOptions} options diff --git a/app/scripts/lib/rpc-method-middleware/handlers/watch-asset.js b/app/scripts/lib/rpc-method-middleware/handlers/watch-asset.js index fdfacb373c77..129005dacf33 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/watch-asset.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/watch-asset.js @@ -23,8 +23,8 @@ export default watchAsset; */ /** - * @param {import('json-rpc-engine').JsonRpcRequest} req - The JSON-RPC request object. - * @param {import('json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. + * @param {import('@metamask/json-rpc-engine').JsonRpcRequest} req - The JSON-RPC request object. + * @param {import('@metamask/json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. * @param {Function} _next - The json-rpc-engine 'next' callback. * @param {Function} end - The json-rpc-engine 'end' callback. * @param {WatchAssetOptions} options diff --git a/app/scripts/lib/tx-verification/tx-verification-middleware.ts b/app/scripts/lib/tx-verification/tx-verification-middleware.ts index 5349feaf1cf9..ff3b418eec60 100644 --- a/app/scripts/lib/tx-verification/tx-verification-middleware.ts +++ b/app/scripts/lib/tx-verification/tx-verification-middleware.ts @@ -8,8 +8,8 @@ import type { JsonRpcResponse, JsonRpcEngineEndCallback, JsonRpcEngineNextCallback, -} from 'json-rpc-engine'; -import { JsonRpcRequest } from 'json-rpc-engine'; +} from '@metamask/json-rpc-engine'; +import { JsonRpcRequest } from '@metamask/json-rpc-engine'; import { EXPERIENCES_TO_VERIFY, getExperience, diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index f7832f5893ec..abf4ad2067cb 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -13,9 +13,9 @@ import { RatesController, fetchMultiExchangeRate, } from '@metamask/assets-controllers'; +import { JsonRpcEngine } from '@metamask/json-rpc-engine'; import { ObservableStore } from '@metamask/obs-store'; import { storeAsStream } from '@metamask/obs-store/dist/asStream'; -import { JsonRpcEngine } from 'json-rpc-engine'; import { createEngineStream } from 'json-rpc-middleware-stream'; import { providerAsMiddleware } from '@metamask/eth-json-rpc-middleware'; import { debounce, throttle, memoize, wrap } from 'lodash'; diff --git a/package.json b/package.json index 3e51e31e1380..fc34c2f9c15f 100644 --- a/package.json +++ b/package.json @@ -323,6 +323,7 @@ "@metamask/ethjs-query": "^0.7.1", "@metamask/gas-fee-controller": "^18.0.0", "@metamask/jazzicon": "^2.0.0", + "@metamask/json-rpc-engine": "^7.3.3", "@metamask/keyring-api": "^8.1.3", "@metamask/keyring-controller": "^17.2.2", "@metamask/logging-controller": "^6.0.0", @@ -401,7 +402,6 @@ "immer": "^9.0.6", "is-retry-allowed": "^2.2.0", "jest-junit": "^14.0.1", - "json-rpc-engine": "^6.1.0", "json-rpc-middleware-stream": "^5.0.1", "labeled-stream-splicer": "^2.0.2", "localforage": "^1.9.0", diff --git a/test/stub/provider.js b/test/stub/provider.js index e070d55fa6b0..f86762218adf 100644 --- a/test/stub/provider.js +++ b/test/stub/provider.js @@ -1,4 +1,7 @@ -import { JsonRpcEngine, createScaffoldMiddleware } from 'json-rpc-engine'; +import { + JsonRpcEngine, + createScaffoldMiddleware, +} from '@metamask/json-rpc-engine'; import { providerAsMiddleware } from '@metamask/eth-json-rpc-middleware'; import Ganache from 'ganache'; diff --git a/yarn.lock b/yarn.lock index 186f52706a3e..2e639921a680 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5581,7 +5581,7 @@ __metadata: languageName: node linkType: hard -"@metamask/json-rpc-engine@npm:^7.1.0, @metamask/json-rpc-engine@npm:^7.1.1, @metamask/json-rpc-engine@npm:^7.3.2": +"@metamask/json-rpc-engine@npm:^7.1.0, @metamask/json-rpc-engine@npm:^7.1.1, @metamask/json-rpc-engine@npm:^7.3.2, @metamask/json-rpc-engine@npm:^7.3.3": version: 7.3.3 resolution: "@metamask/json-rpc-engine@npm:7.3.3" dependencies: @@ -18479,15 +18479,6 @@ __metadata: languageName: node linkType: hard -"eth-rpc-errors@npm:^4.0.2": - version: 4.0.3 - resolution: "eth-rpc-errors@npm:4.0.3" - dependencies: - fast-safe-stringify: "npm:^2.0.6" - checksum: 10/47ce14170eabaee51ab1cc7e643bb3ef96ee6b15c6404806aedcd51750e00ae0b1a12c37785b180679b8d452b6dd44a0240bb018d01fa73efc85fcfa808b35a7 - languageName: node - linkType: hard - "ethereum-cryptography@npm:^0.1.3": version: 0.1.3 resolution: "ethereum-cryptography@npm:0.1.3" @@ -24179,16 +24170,6 @@ __metadata: languageName: node linkType: hard -"json-rpc-engine@npm:^6.1.0": - version: 6.1.0 - resolution: "json-rpc-engine@npm:6.1.0" - dependencies: - "@metamask/safe-event-emitter": "npm:^2.0.0" - eth-rpc-errors: "npm:^4.0.2" - checksum: 10/00d5b5228e90f126dd52176598db6e5611d295d3a3f7be21254c30c1b6555811260ef2ec2df035cd8e583e4b12096259da721e29f4ea2affb615f7dfc960a6a6 - languageName: node - linkType: hard - "json-rpc-middleware-stream@npm:^5.0.1": version: 5.0.1 resolution: "json-rpc-middleware-stream@npm:5.0.1" @@ -26130,6 +26111,7 @@ __metadata: "@metamask/forwarder": "npm:^1.1.0" "@metamask/gas-fee-controller": "npm:^18.0.0" "@metamask/jazzicon": "npm:^2.0.0" + "@metamask/json-rpc-engine": "npm:^7.3.3" "@metamask/keyring-api": "npm:^8.1.3" "@metamask/keyring-controller": "npm:^17.2.2" "@metamask/logging-controller": "npm:^6.0.0" @@ -26347,7 +26329,6 @@ __metadata: jest-environment-jsdom: "patch:jest-environment-jsdom@npm%3A29.7.0#~/.yarn/patches/jest-environment-jsdom-npm-29.7.0-0b72dd0e0b.patch" jest-junit: "npm:^14.0.1" jsdom: "npm:^16.7.0" - json-rpc-engine: "npm:^6.1.0" json-rpc-middleware-stream: "npm:^5.0.1" json-schema-to-ts: "npm:^3.0.1" koa: "npm:^2.7.0" From 919232f57e5d0b4fdce23b92b8faddbec1926cb0 Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Mon, 6 May 2024 10:58:12 +0000 Subject: [PATCH 02/16] fix: call engine.destroy --- app/scripts/metamask-controller.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index abf4ad2067cb..75a0da28157e 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -5492,11 +5492,7 @@ export default class MetamaskController extends EventEmitter { outStream, (err) => { // handle any middleware cleanup - engine._middleware.forEach((mid) => { - if (mid.destroy && typeof mid.destroy === 'function') { - mid.destroy(); - } - }); + engine.destroy(); connectionId && this.removeConnection(origin, connectionId); // For context and todos related to the error message match, see https://github.com/MetaMask/metamask-extension/issues/26337 if (err && !err.message?.match('Premature close')) { From 33797714fe89464fc8deeedbb9cf52978bac5669 Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Mon, 6 May 2024 11:26:55 +0000 Subject: [PATCH 03/16] fix: adjust error handling for new json-rpc-engine version --- .../lib/createRPCMethodTrackingMiddleware.js | 10 ++- ui/store/actions.ts | 68 +++++++++++-------- 2 files changed, 48 insertions(+), 30 deletions(-) diff --git a/app/scripts/lib/createRPCMethodTrackingMiddleware.js b/app/scripts/lib/createRPCMethodTrackingMiddleware.js index a5f12687f89e..a1c5a036f13f 100644 --- a/app/scripts/lib/createRPCMethodTrackingMiddleware.js +++ b/app/scripts/lib/createRPCMethodTrackingMiddleware.js @@ -18,6 +18,7 @@ import { PRIMARY_TYPES_PERMIT, } from '../../../shared/constants/signatures'; import { SIGNING_METHODS } from '../../../shared/constants/transaction'; +import { getErrorMessage } from '../../../shared/modules/error'; import { generateSignatureUniqueId, getBlockaidMetricsProps, @@ -419,15 +420,20 @@ export default function createRPCMethodTrackingMiddleware({ const location = res.error?.data?.location; let event; + + const errorMessage = getErrorMessage(res.error); + if (res.error?.code === errorCodes.provider.userRejectedRequest) { event = eventType.REJECTED; } else if ( res.error?.code === errorCodes.rpc.internal && - res.error?.message === 'Request rejected by user or snap.' + [errorMessage, res.error.message].includes( + 'Request rejected by user or snap.', + ) ) { // The signature was approved in MetaMask but rejected in the snap event = eventType.REJECTED; - eventProperties.status = res.error.message; + eventProperties.status = errorMessage; } else { event = eventType.APPROVED; } diff --git a/ui/store/actions.ts b/ui/store/actions.ts index 3433a798a9d9..a81dabb5e5c6 100644 --- a/ui/store/actions.ts +++ b/ui/store/actions.ts @@ -182,7 +182,7 @@ export function tryUnlockMetamask( dispatch(hideLoadingIndication()); }) .catch((err) => { - dispatch(unlockFailed(err.message)); + dispatch(unlockFailed(getErrorMessage(err))); dispatch(hideLoadingIndication()); return Promise.reject(err); }); @@ -4213,7 +4213,7 @@ export function setConnectedStatusPopoverHasBeenShown(): ThunkAction< return () => { callBackgroundMethod('setConnectedStatusPopoverHasBeenShown', [], (err) => { if (isErrorWithMessage(err)) { - throw new Error(err.message); + throw new Error(getErrorMessage(err)); } }); }; @@ -4223,7 +4223,7 @@ export function setRecoveryPhraseReminderHasBeenShown() { return () => { callBackgroundMethod('setRecoveryPhraseReminderHasBeenShown', [], (err) => { if (isErrorWithMessage(err)) { - throw new Error(err.message); + throw new Error(getErrorMessage(err)); } }); }; @@ -4238,7 +4238,7 @@ export function setRecoveryPhraseReminderLastShown( [lastShown], (err) => { if (isErrorWithMessage(err)) { - throw new Error(err.message); + throw new Error(getErrorMessage(err)); } }, ); @@ -4723,12 +4723,15 @@ export function fetchSmartTransactionFees( return smartTransactionFees; } catch (err) { logErrorWithMessage(err); - if (isErrorWithMessage(err) && err.message.startsWith('Fetch error:')) { - const errorObj = parseSmartTransactionsError(err.message); - dispatch({ - type: actionConstants.SET_SMART_TRANSACTIONS_ERROR, - payload: errorObj, - }); + if (isErrorWithMessage(err)) { + const errorMessage = getErrorMessage(err); + if (errorMessage.startsWith('Fetch error:')) { + const errorObj = parseSmartTransactionsError(errorMessage); + dispatch({ + type: actionConstants.SET_SMART_TRANSACTIONS_ERROR, + payload: errorObj, + }); + } } throw err; } @@ -4800,12 +4803,15 @@ export function signAndSendSmartTransaction({ return response.uuid; } catch (err) { logErrorWithMessage(err); - if (isErrorWithMessage(err) && err.message.startsWith('Fetch error:')) { - const errorObj = parseSmartTransactionsError(err.message); - dispatch({ - type: actionConstants.SET_SMART_TRANSACTIONS_ERROR, - payload: errorObj, - }); + if (isErrorWithMessage(err)) { + const errorMessage = getErrorMessage(err); + if (errorMessage.startsWith('Fetch error:')) { + const errorObj = parseSmartTransactionsError(errorMessage); + dispatch({ + type: actionConstants.SET_SMART_TRANSACTIONS_ERROR, + payload: errorObj, + }); + } } throw err; } @@ -4826,12 +4832,15 @@ export function updateSmartTransaction( ]); } catch (err) { logErrorWithMessage(err); - if (isErrorWithMessage(err) && err.message.startsWith('Fetch error:')) { - const errorObj = parseSmartTransactionsError(err.message); - dispatch({ - type: actionConstants.SET_SMART_TRANSACTIONS_ERROR, - payload: errorObj, - }); + if (isErrorWithMessage(err)) { + const errorMessage = getErrorMessage(err); + if (errorMessage.startsWith('Fetch error:')) { + const errorObj = parseSmartTransactionsError(errorMessage); + dispatch({ + type: actionConstants.SET_SMART_TRANSACTIONS_ERROR, + payload: errorObj, + }); + } } throw err; } @@ -4860,12 +4869,15 @@ export function cancelSmartTransaction( await submitRequestToBackground('cancelSmartTransaction', [uuid]); } catch (err) { logErrorWithMessage(err); - if (isErrorWithMessage(err) && err.message.startsWith('Fetch error:')) { - const errorObj = parseSmartTransactionsError(err.message); - dispatch({ - type: actionConstants.SET_SMART_TRANSACTIONS_ERROR, - payload: errorObj, - }); + if (isErrorWithMessage(err)) { + const errorMessage = getErrorMessage(err); + if (errorMessage.startsWith('Fetch error:')) { + const errorObj = parseSmartTransactionsError(errorMessage); + dispatch({ + type: actionConstants.SET_SMART_TRANSACTIONS_ERROR, + payload: errorObj, + }); + } } throw err; } From 0ecc38d07ef8400094e8c36bf719d1acbefb3966 Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Fri, 31 May 2024 05:26:01 +0000 Subject: [PATCH 04/16] chore: update expected test results --- .../rpc-method-middleware/createMethodMiddleware.test.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/scripts/lib/rpc-method-middleware/createMethodMiddleware.test.js b/app/scripts/lib/rpc-method-middleware/createMethodMiddleware.test.js index c91d0d0dc02c..491d62b33b7b 100644 --- a/app/scripts/lib/rpc-method-middleware/createMethodMiddleware.test.js +++ b/app/scripts/lib/rpc-method-middleware/createMethodMiddleware.test.js @@ -139,7 +139,8 @@ describe.each([ }); assertIsJsonRpcFailure(response); - expect(response.error.message).toBe('test error'); + expect(response.error.message).toBe('Internal JSON-RPC error.'); + expect(response.error.cause.message).toBe('test error'); }); it('should handle errors thrown by the implementation', async () => { @@ -155,7 +156,8 @@ describe.each([ }); assertIsJsonRpcFailure(response); - expect(response.error.message).toBe('test error'); + expect(response.error.message).toBe('Internal JSON-RPC error.'); + expect(response.error.cause.message).toBe('test error'); }); it('should handle non-errors thrown by the implementation', async () => { From 0bb5f3c4c5d2e71aa0fc09c84885f2df7a6f5252 Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Fri, 31 May 2024 05:30:21 +0000 Subject: [PATCH 05/16] update lavamoat policies --- lavamoat/browserify/beta/policy.json | 223 ++++++++++++++++---------- lavamoat/browserify/flask/policy.json | 223 ++++++++++++++++---------- lavamoat/browserify/main/policy.json | 223 ++++++++++++++++---------- lavamoat/browserify/mmi/policy.json | 223 ++++++++++++++++---------- 4 files changed, 540 insertions(+), 352 deletions(-) diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json index 27b06f2ba5b8..2d2289e97931 100644 --- a/lavamoat/browserify/beta/policy.json +++ b/lavamoat/browserify/beta/policy.json @@ -849,8 +849,8 @@ }, "packages": { "@metamask/eth-json-rpc-filters>@metamask/eth-query": true, - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine": true, "@metamask/eth-json-rpc-filters>async-mutex": true, + "@metamask/json-rpc-engine": true, "@metamask/safe-event-emitter": true, "pify": true } @@ -861,49 +861,6 @@ "watchify>xtend": true } }, - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine": { - "packages": { - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/rpc-errors": true, - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/utils": true, - "@metamask/safe-event-emitter": true - } - }, - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/rpc-errors": { - "packages": { - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/rpc-errors>@metamask/utils": true, - "@metamask/rpc-errors>fast-safe-stringify": true - } - }, - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@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/eth-json-rpc-filters>@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/eth-json-rpc-filters>async-mutex": { "globals": { "setTimeout": true @@ -919,11 +876,18 @@ "setTimeout": true }, "packages": { + "@metamask/eth-json-rpc-middleware>@metamask/json-rpc-engine": true, "@metamask/eth-json-rpc-middleware>@metamask/rpc-errors": true, "@metamask/eth-json-rpc-middleware>klona": true, "@metamask/eth-json-rpc-middleware>safe-stable-stringify": true, "@metamask/eth-sig-util": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, + "@metamask/utils": true + } + }, + "@metamask/eth-json-rpc-middleware>@metamask/json-rpc-engine": { + "packages": { + "@metamask/eth-json-rpc-middleware>@metamask/rpc-errors": true, + "@metamask/safe-event-emitter": true, "@metamask/utils": true } }, @@ -1345,6 +1309,49 @@ "jest-canvas-mock>moo-color>color-name": true } }, + "@metamask/json-rpc-engine": { + "packages": { + "@metamask/json-rpc-engine>@metamask/rpc-errors": true, + "@metamask/json-rpc-engine>@metamask/utils": true, + "@metamask/safe-event-emitter": true + } + }, + "@metamask/json-rpc-engine>@metamask/rpc-errors": { + "packages": { + "@metamask/json-rpc-engine>@metamask/rpc-errors>@metamask/utils": true, + "@metamask/rpc-errors>fast-safe-stringify": true + } + }, + "@metamask/json-rpc-engine>@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/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/keyring-api": { "globals": { "URL": true @@ -1544,10 +1551,10 @@ "@metamask/network-controller>@metamask/eth-json-rpc-infura": true, "@metamask/network-controller>@metamask/eth-json-rpc-middleware": true, "@metamask/network-controller>@metamask/eth-json-rpc-provider": true, + "@metamask/network-controller>@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/rpc-errors": true, "@metamask/network-controller>@metamask/swappable-obj-proxy": true, "@metamask/network-controller>reselect": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, "@metamask/utils": true, "browserify>assert": true, "browserify>util": true, @@ -1588,8 +1595,8 @@ "setTimeout": true }, "packages": { + "@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/eth-json-rpc-provider": true, - "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/rpc-errors": true, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/utils": true, "node-fetch": true @@ -1597,14 +1604,7 @@ }, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/eth-json-rpc-provider": { "packages": { - "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/json-rpc-engine": true, - "@metamask/safe-event-emitter": true - } - }, - "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/json-rpc-engine": { - "packages": { - "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/rpc-errors": true, - "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/utils": true, + "@metamask/json-rpc-engine": true, "@metamask/safe-event-emitter": true } }, @@ -1655,8 +1655,8 @@ "@metamask/eth-json-rpc-middleware>safe-stable-stringify": true, "@metamask/eth-sig-util": true, "@metamask/network-controller>@metamask/eth-json-rpc-middleware>@metamask/utils": true, + "@metamask/network-controller>@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/rpc-errors": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, "bn.js": true, "pify": true } @@ -1678,18 +1678,32 @@ }, "@metamask/network-controller>@metamask/eth-json-rpc-provider": { "packages": { + "@metamask/network-controller>@metamask/eth-json-rpc-provider>@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/eth-json-rpc-provider>@metamask/rpc-errors": true, "@metamask/safe-event-emitter": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, "uuid": true } }, + "@metamask/network-controller>@metamask/eth-json-rpc-provider>@metamask/json-rpc-engine": { + "packages": { + "@metamask/network-controller>@metamask/eth-json-rpc-provider>@metamask/rpc-errors": true, + "@metamask/safe-event-emitter": true, + "@metamask/utils": true + } + }, "@metamask/network-controller>@metamask/eth-json-rpc-provider>@metamask/rpc-errors": { "packages": { "@metamask/rpc-errors>fast-safe-stringify": true, "@metamask/utils": true } }, + "@metamask/network-controller>@metamask/json-rpc-engine": { + "packages": { + "@metamask/network-controller>@metamask/rpc-errors": true, + "@metamask/safe-event-emitter": true, + "@metamask/utils": true + } + }, "@metamask/network-controller>@metamask/rpc-errors": { "packages": { "@metamask/rpc-errors>fast-safe-stringify": true, @@ -1904,10 +1918,10 @@ "packages": { "@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/permission-controller>nanoid": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, "deep-freeze-strict": true, "immer": true } @@ -1920,6 +1934,28 @@ "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, @@ -2147,10 +2183,10 @@ "@metamask/queued-request-controller": { "packages": { "@metamask/queued-request-controller>@metamask/base-controller": true, + "@metamask/queued-request-controller>@metamask/json-rpc-engine": true, "@metamask/queued-request-controller>@metamask/rpc-errors": true, "@metamask/queued-request-controller>@metamask/utils": true, - "@metamask/selected-network-controller": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true + "@metamask/selected-network-controller": true } }, "@metamask/queued-request-controller>@metamask/base-controller": { @@ -2161,6 +2197,28 @@ "immer": true } }, + "@metamask/queued-request-controller>@metamask/json-rpc-engine": { + "packages": { + "@metamask/queued-request-controller>@metamask/json-rpc-engine>@metamask/utils": true, + "@metamask/queued-request-controller>@metamask/rpc-errors": true, + "@metamask/safe-event-emitter": true + } + }, + "@metamask/queued-request-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/queued-request-controller>@metamask/rpc-errors": { "packages": { "@metamask/queued-request-controller>@metamask/rpc-errors>@metamask/utils": true, @@ -2586,13 +2644,7 @@ "@metamask/snaps-controllers>@metamask/json-rpc-engine": { "packages": { "@metamask/safe-event-emitter": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/rpc-errors": true, - "@metamask/utils": true - } - }, - "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/rpc-errors": { - "packages": { - "@metamask/rpc-errors>fast-safe-stringify": true, + "@metamask/snaps-controllers>@metamask/rpc-errors": true, "@metamask/utils": true } }, @@ -2701,8 +2753,8 @@ }, "packages": { "@metamask/controller-utils": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, "@metamask/snaps-rpc-methods>@metamask/permission-controller>@metamask/base-controller": true, + "@metamask/snaps-rpc-methods>@metamask/permission-controller>@metamask/json-rpc-engine": true, "@metamask/snaps-rpc-methods>@metamask/permission-controller>nanoid": true, "@metamask/snaps-rpc-methods>@metamask/rpc-errors": true, "@metamask/utils": true, @@ -2718,6 +2770,13 @@ "immer": true } }, + "@metamask/snaps-rpc-methods>@metamask/permission-controller>@metamask/json-rpc-engine": { + "packages": { + "@metamask/safe-event-emitter": true, + "@metamask/snaps-rpc-methods>@metamask/rpc-errors": true, + "@metamask/utils": true + } + }, "@metamask/snaps-rpc-methods>@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -2803,8 +2862,8 @@ }, "packages": { "@metamask/controller-utils": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, "@metamask/snaps-utils>@metamask/base-controller": true, + "@metamask/snaps-utils>@metamask/permission-controller>@metamask/json-rpc-engine": true, "@metamask/snaps-utils>@metamask/permission-controller>nanoid": true, "@metamask/snaps-utils>@metamask/rpc-errors": true, "@metamask/utils": true, @@ -2812,6 +2871,13 @@ "immer": true } }, + "@metamask/snaps-utils>@metamask/permission-controller>@metamask/json-rpc-engine": { + "packages": { + "@metamask/safe-event-emitter": true, + "@metamask/snaps-utils>@metamask/rpc-errors": true, + "@metamask/utils": true + } + }, "@metamask/snaps-utils>@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -4674,25 +4740,6 @@ "stream-http": true } }, - "json-rpc-engine": { - "packages": { - "json-rpc-engine>@metamask/safe-event-emitter": true, - "json-rpc-engine>eth-rpc-errors": true - } - }, - "json-rpc-engine>@metamask/safe-event-emitter": { - "globals": { - "setTimeout": true - }, - "packages": { - "webpack>events": true - } - }, - "json-rpc-engine>eth-rpc-errors": { - "packages": { - "@metamask/rpc-errors>fast-safe-stringify": true - } - }, "json-rpc-middleware-stream": { "globals": { "console.warn": true, diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json index 27b06f2ba5b8..2d2289e97931 100644 --- a/lavamoat/browserify/flask/policy.json +++ b/lavamoat/browserify/flask/policy.json @@ -849,8 +849,8 @@ }, "packages": { "@metamask/eth-json-rpc-filters>@metamask/eth-query": true, - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine": true, "@metamask/eth-json-rpc-filters>async-mutex": true, + "@metamask/json-rpc-engine": true, "@metamask/safe-event-emitter": true, "pify": true } @@ -861,49 +861,6 @@ "watchify>xtend": true } }, - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine": { - "packages": { - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/rpc-errors": true, - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/utils": true, - "@metamask/safe-event-emitter": true - } - }, - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/rpc-errors": { - "packages": { - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/rpc-errors>@metamask/utils": true, - "@metamask/rpc-errors>fast-safe-stringify": true - } - }, - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@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/eth-json-rpc-filters>@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/eth-json-rpc-filters>async-mutex": { "globals": { "setTimeout": true @@ -919,11 +876,18 @@ "setTimeout": true }, "packages": { + "@metamask/eth-json-rpc-middleware>@metamask/json-rpc-engine": true, "@metamask/eth-json-rpc-middleware>@metamask/rpc-errors": true, "@metamask/eth-json-rpc-middleware>klona": true, "@metamask/eth-json-rpc-middleware>safe-stable-stringify": true, "@metamask/eth-sig-util": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, + "@metamask/utils": true + } + }, + "@metamask/eth-json-rpc-middleware>@metamask/json-rpc-engine": { + "packages": { + "@metamask/eth-json-rpc-middleware>@metamask/rpc-errors": true, + "@metamask/safe-event-emitter": true, "@metamask/utils": true } }, @@ -1345,6 +1309,49 @@ "jest-canvas-mock>moo-color>color-name": true } }, + "@metamask/json-rpc-engine": { + "packages": { + "@metamask/json-rpc-engine>@metamask/rpc-errors": true, + "@metamask/json-rpc-engine>@metamask/utils": true, + "@metamask/safe-event-emitter": true + } + }, + "@metamask/json-rpc-engine>@metamask/rpc-errors": { + "packages": { + "@metamask/json-rpc-engine>@metamask/rpc-errors>@metamask/utils": true, + "@metamask/rpc-errors>fast-safe-stringify": true + } + }, + "@metamask/json-rpc-engine>@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/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/keyring-api": { "globals": { "URL": true @@ -1544,10 +1551,10 @@ "@metamask/network-controller>@metamask/eth-json-rpc-infura": true, "@metamask/network-controller>@metamask/eth-json-rpc-middleware": true, "@metamask/network-controller>@metamask/eth-json-rpc-provider": true, + "@metamask/network-controller>@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/rpc-errors": true, "@metamask/network-controller>@metamask/swappable-obj-proxy": true, "@metamask/network-controller>reselect": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, "@metamask/utils": true, "browserify>assert": true, "browserify>util": true, @@ -1588,8 +1595,8 @@ "setTimeout": true }, "packages": { + "@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/eth-json-rpc-provider": true, - "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/rpc-errors": true, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/utils": true, "node-fetch": true @@ -1597,14 +1604,7 @@ }, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/eth-json-rpc-provider": { "packages": { - "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/json-rpc-engine": true, - "@metamask/safe-event-emitter": true - } - }, - "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/json-rpc-engine": { - "packages": { - "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/rpc-errors": true, - "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/utils": true, + "@metamask/json-rpc-engine": true, "@metamask/safe-event-emitter": true } }, @@ -1655,8 +1655,8 @@ "@metamask/eth-json-rpc-middleware>safe-stable-stringify": true, "@metamask/eth-sig-util": true, "@metamask/network-controller>@metamask/eth-json-rpc-middleware>@metamask/utils": true, + "@metamask/network-controller>@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/rpc-errors": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, "bn.js": true, "pify": true } @@ -1678,18 +1678,32 @@ }, "@metamask/network-controller>@metamask/eth-json-rpc-provider": { "packages": { + "@metamask/network-controller>@metamask/eth-json-rpc-provider>@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/eth-json-rpc-provider>@metamask/rpc-errors": true, "@metamask/safe-event-emitter": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, "uuid": true } }, + "@metamask/network-controller>@metamask/eth-json-rpc-provider>@metamask/json-rpc-engine": { + "packages": { + "@metamask/network-controller>@metamask/eth-json-rpc-provider>@metamask/rpc-errors": true, + "@metamask/safe-event-emitter": true, + "@metamask/utils": true + } + }, "@metamask/network-controller>@metamask/eth-json-rpc-provider>@metamask/rpc-errors": { "packages": { "@metamask/rpc-errors>fast-safe-stringify": true, "@metamask/utils": true } }, + "@metamask/network-controller>@metamask/json-rpc-engine": { + "packages": { + "@metamask/network-controller>@metamask/rpc-errors": true, + "@metamask/safe-event-emitter": true, + "@metamask/utils": true + } + }, "@metamask/network-controller>@metamask/rpc-errors": { "packages": { "@metamask/rpc-errors>fast-safe-stringify": true, @@ -1904,10 +1918,10 @@ "packages": { "@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/permission-controller>nanoid": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, "deep-freeze-strict": true, "immer": true } @@ -1920,6 +1934,28 @@ "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, @@ -2147,10 +2183,10 @@ "@metamask/queued-request-controller": { "packages": { "@metamask/queued-request-controller>@metamask/base-controller": true, + "@metamask/queued-request-controller>@metamask/json-rpc-engine": true, "@metamask/queued-request-controller>@metamask/rpc-errors": true, "@metamask/queued-request-controller>@metamask/utils": true, - "@metamask/selected-network-controller": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true + "@metamask/selected-network-controller": true } }, "@metamask/queued-request-controller>@metamask/base-controller": { @@ -2161,6 +2197,28 @@ "immer": true } }, + "@metamask/queued-request-controller>@metamask/json-rpc-engine": { + "packages": { + "@metamask/queued-request-controller>@metamask/json-rpc-engine>@metamask/utils": true, + "@metamask/queued-request-controller>@metamask/rpc-errors": true, + "@metamask/safe-event-emitter": true + } + }, + "@metamask/queued-request-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/queued-request-controller>@metamask/rpc-errors": { "packages": { "@metamask/queued-request-controller>@metamask/rpc-errors>@metamask/utils": true, @@ -2586,13 +2644,7 @@ "@metamask/snaps-controllers>@metamask/json-rpc-engine": { "packages": { "@metamask/safe-event-emitter": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/rpc-errors": true, - "@metamask/utils": true - } - }, - "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/rpc-errors": { - "packages": { - "@metamask/rpc-errors>fast-safe-stringify": true, + "@metamask/snaps-controllers>@metamask/rpc-errors": true, "@metamask/utils": true } }, @@ -2701,8 +2753,8 @@ }, "packages": { "@metamask/controller-utils": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, "@metamask/snaps-rpc-methods>@metamask/permission-controller>@metamask/base-controller": true, + "@metamask/snaps-rpc-methods>@metamask/permission-controller>@metamask/json-rpc-engine": true, "@metamask/snaps-rpc-methods>@metamask/permission-controller>nanoid": true, "@metamask/snaps-rpc-methods>@metamask/rpc-errors": true, "@metamask/utils": true, @@ -2718,6 +2770,13 @@ "immer": true } }, + "@metamask/snaps-rpc-methods>@metamask/permission-controller>@metamask/json-rpc-engine": { + "packages": { + "@metamask/safe-event-emitter": true, + "@metamask/snaps-rpc-methods>@metamask/rpc-errors": true, + "@metamask/utils": true + } + }, "@metamask/snaps-rpc-methods>@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -2803,8 +2862,8 @@ }, "packages": { "@metamask/controller-utils": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, "@metamask/snaps-utils>@metamask/base-controller": true, + "@metamask/snaps-utils>@metamask/permission-controller>@metamask/json-rpc-engine": true, "@metamask/snaps-utils>@metamask/permission-controller>nanoid": true, "@metamask/snaps-utils>@metamask/rpc-errors": true, "@metamask/utils": true, @@ -2812,6 +2871,13 @@ "immer": true } }, + "@metamask/snaps-utils>@metamask/permission-controller>@metamask/json-rpc-engine": { + "packages": { + "@metamask/safe-event-emitter": true, + "@metamask/snaps-utils>@metamask/rpc-errors": true, + "@metamask/utils": true + } + }, "@metamask/snaps-utils>@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -4674,25 +4740,6 @@ "stream-http": true } }, - "json-rpc-engine": { - "packages": { - "json-rpc-engine>@metamask/safe-event-emitter": true, - "json-rpc-engine>eth-rpc-errors": true - } - }, - "json-rpc-engine>@metamask/safe-event-emitter": { - "globals": { - "setTimeout": true - }, - "packages": { - "webpack>events": true - } - }, - "json-rpc-engine>eth-rpc-errors": { - "packages": { - "@metamask/rpc-errors>fast-safe-stringify": true - } - }, "json-rpc-middleware-stream": { "globals": { "console.warn": true, diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json index 27b06f2ba5b8..2d2289e97931 100644 --- a/lavamoat/browserify/main/policy.json +++ b/lavamoat/browserify/main/policy.json @@ -849,8 +849,8 @@ }, "packages": { "@metamask/eth-json-rpc-filters>@metamask/eth-query": true, - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine": true, "@metamask/eth-json-rpc-filters>async-mutex": true, + "@metamask/json-rpc-engine": true, "@metamask/safe-event-emitter": true, "pify": true } @@ -861,49 +861,6 @@ "watchify>xtend": true } }, - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine": { - "packages": { - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/rpc-errors": true, - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/utils": true, - "@metamask/safe-event-emitter": true - } - }, - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/rpc-errors": { - "packages": { - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/rpc-errors>@metamask/utils": true, - "@metamask/rpc-errors>fast-safe-stringify": true - } - }, - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@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/eth-json-rpc-filters>@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/eth-json-rpc-filters>async-mutex": { "globals": { "setTimeout": true @@ -919,11 +876,18 @@ "setTimeout": true }, "packages": { + "@metamask/eth-json-rpc-middleware>@metamask/json-rpc-engine": true, "@metamask/eth-json-rpc-middleware>@metamask/rpc-errors": true, "@metamask/eth-json-rpc-middleware>klona": true, "@metamask/eth-json-rpc-middleware>safe-stable-stringify": true, "@metamask/eth-sig-util": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, + "@metamask/utils": true + } + }, + "@metamask/eth-json-rpc-middleware>@metamask/json-rpc-engine": { + "packages": { + "@metamask/eth-json-rpc-middleware>@metamask/rpc-errors": true, + "@metamask/safe-event-emitter": true, "@metamask/utils": true } }, @@ -1345,6 +1309,49 @@ "jest-canvas-mock>moo-color>color-name": true } }, + "@metamask/json-rpc-engine": { + "packages": { + "@metamask/json-rpc-engine>@metamask/rpc-errors": true, + "@metamask/json-rpc-engine>@metamask/utils": true, + "@metamask/safe-event-emitter": true + } + }, + "@metamask/json-rpc-engine>@metamask/rpc-errors": { + "packages": { + "@metamask/json-rpc-engine>@metamask/rpc-errors>@metamask/utils": true, + "@metamask/rpc-errors>fast-safe-stringify": true + } + }, + "@metamask/json-rpc-engine>@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/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/keyring-api": { "globals": { "URL": true @@ -1544,10 +1551,10 @@ "@metamask/network-controller>@metamask/eth-json-rpc-infura": true, "@metamask/network-controller>@metamask/eth-json-rpc-middleware": true, "@metamask/network-controller>@metamask/eth-json-rpc-provider": true, + "@metamask/network-controller>@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/rpc-errors": true, "@metamask/network-controller>@metamask/swappable-obj-proxy": true, "@metamask/network-controller>reselect": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, "@metamask/utils": true, "browserify>assert": true, "browserify>util": true, @@ -1588,8 +1595,8 @@ "setTimeout": true }, "packages": { + "@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/eth-json-rpc-provider": true, - "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/rpc-errors": true, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/utils": true, "node-fetch": true @@ -1597,14 +1604,7 @@ }, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/eth-json-rpc-provider": { "packages": { - "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/json-rpc-engine": true, - "@metamask/safe-event-emitter": true - } - }, - "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/json-rpc-engine": { - "packages": { - "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/rpc-errors": true, - "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/utils": true, + "@metamask/json-rpc-engine": true, "@metamask/safe-event-emitter": true } }, @@ -1655,8 +1655,8 @@ "@metamask/eth-json-rpc-middleware>safe-stable-stringify": true, "@metamask/eth-sig-util": true, "@metamask/network-controller>@metamask/eth-json-rpc-middleware>@metamask/utils": true, + "@metamask/network-controller>@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/rpc-errors": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, "bn.js": true, "pify": true } @@ -1678,18 +1678,32 @@ }, "@metamask/network-controller>@metamask/eth-json-rpc-provider": { "packages": { + "@metamask/network-controller>@metamask/eth-json-rpc-provider>@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/eth-json-rpc-provider>@metamask/rpc-errors": true, "@metamask/safe-event-emitter": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, "uuid": true } }, + "@metamask/network-controller>@metamask/eth-json-rpc-provider>@metamask/json-rpc-engine": { + "packages": { + "@metamask/network-controller>@metamask/eth-json-rpc-provider>@metamask/rpc-errors": true, + "@metamask/safe-event-emitter": true, + "@metamask/utils": true + } + }, "@metamask/network-controller>@metamask/eth-json-rpc-provider>@metamask/rpc-errors": { "packages": { "@metamask/rpc-errors>fast-safe-stringify": true, "@metamask/utils": true } }, + "@metamask/network-controller>@metamask/json-rpc-engine": { + "packages": { + "@metamask/network-controller>@metamask/rpc-errors": true, + "@metamask/safe-event-emitter": true, + "@metamask/utils": true + } + }, "@metamask/network-controller>@metamask/rpc-errors": { "packages": { "@metamask/rpc-errors>fast-safe-stringify": true, @@ -1904,10 +1918,10 @@ "packages": { "@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/permission-controller>nanoid": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, "deep-freeze-strict": true, "immer": true } @@ -1920,6 +1934,28 @@ "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, @@ -2147,10 +2183,10 @@ "@metamask/queued-request-controller": { "packages": { "@metamask/queued-request-controller>@metamask/base-controller": true, + "@metamask/queued-request-controller>@metamask/json-rpc-engine": true, "@metamask/queued-request-controller>@metamask/rpc-errors": true, "@metamask/queued-request-controller>@metamask/utils": true, - "@metamask/selected-network-controller": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true + "@metamask/selected-network-controller": true } }, "@metamask/queued-request-controller>@metamask/base-controller": { @@ -2161,6 +2197,28 @@ "immer": true } }, + "@metamask/queued-request-controller>@metamask/json-rpc-engine": { + "packages": { + "@metamask/queued-request-controller>@metamask/json-rpc-engine>@metamask/utils": true, + "@metamask/queued-request-controller>@metamask/rpc-errors": true, + "@metamask/safe-event-emitter": true + } + }, + "@metamask/queued-request-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/queued-request-controller>@metamask/rpc-errors": { "packages": { "@metamask/queued-request-controller>@metamask/rpc-errors>@metamask/utils": true, @@ -2586,13 +2644,7 @@ "@metamask/snaps-controllers>@metamask/json-rpc-engine": { "packages": { "@metamask/safe-event-emitter": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/rpc-errors": true, - "@metamask/utils": true - } - }, - "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/rpc-errors": { - "packages": { - "@metamask/rpc-errors>fast-safe-stringify": true, + "@metamask/snaps-controllers>@metamask/rpc-errors": true, "@metamask/utils": true } }, @@ -2701,8 +2753,8 @@ }, "packages": { "@metamask/controller-utils": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, "@metamask/snaps-rpc-methods>@metamask/permission-controller>@metamask/base-controller": true, + "@metamask/snaps-rpc-methods>@metamask/permission-controller>@metamask/json-rpc-engine": true, "@metamask/snaps-rpc-methods>@metamask/permission-controller>nanoid": true, "@metamask/snaps-rpc-methods>@metamask/rpc-errors": true, "@metamask/utils": true, @@ -2718,6 +2770,13 @@ "immer": true } }, + "@metamask/snaps-rpc-methods>@metamask/permission-controller>@metamask/json-rpc-engine": { + "packages": { + "@metamask/safe-event-emitter": true, + "@metamask/snaps-rpc-methods>@metamask/rpc-errors": true, + "@metamask/utils": true + } + }, "@metamask/snaps-rpc-methods>@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -2803,8 +2862,8 @@ }, "packages": { "@metamask/controller-utils": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, "@metamask/snaps-utils>@metamask/base-controller": true, + "@metamask/snaps-utils>@metamask/permission-controller>@metamask/json-rpc-engine": true, "@metamask/snaps-utils>@metamask/permission-controller>nanoid": true, "@metamask/snaps-utils>@metamask/rpc-errors": true, "@metamask/utils": true, @@ -2812,6 +2871,13 @@ "immer": true } }, + "@metamask/snaps-utils>@metamask/permission-controller>@metamask/json-rpc-engine": { + "packages": { + "@metamask/safe-event-emitter": true, + "@metamask/snaps-utils>@metamask/rpc-errors": true, + "@metamask/utils": true + } + }, "@metamask/snaps-utils>@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -4674,25 +4740,6 @@ "stream-http": true } }, - "json-rpc-engine": { - "packages": { - "json-rpc-engine>@metamask/safe-event-emitter": true, - "json-rpc-engine>eth-rpc-errors": true - } - }, - "json-rpc-engine>@metamask/safe-event-emitter": { - "globals": { - "setTimeout": true - }, - "packages": { - "webpack>events": true - } - }, - "json-rpc-engine>eth-rpc-errors": { - "packages": { - "@metamask/rpc-errors>fast-safe-stringify": true - } - }, "json-rpc-middleware-stream": { "globals": { "console.warn": true, diff --git a/lavamoat/browserify/mmi/policy.json b/lavamoat/browserify/mmi/policy.json index 7c19b1b4c76e..86eb589ad8d6 100644 --- a/lavamoat/browserify/mmi/policy.json +++ b/lavamoat/browserify/mmi/policy.json @@ -941,8 +941,8 @@ }, "packages": { "@metamask/eth-json-rpc-filters>@metamask/eth-query": true, - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine": true, "@metamask/eth-json-rpc-filters>async-mutex": true, + "@metamask/json-rpc-engine": true, "@metamask/safe-event-emitter": true, "pify": true } @@ -953,49 +953,6 @@ "watchify>xtend": true } }, - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine": { - "packages": { - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/rpc-errors": true, - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/utils": true, - "@metamask/safe-event-emitter": true - } - }, - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/rpc-errors": { - "packages": { - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/rpc-errors>@metamask/utils": true, - "@metamask/rpc-errors>fast-safe-stringify": true - } - }, - "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@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/eth-json-rpc-filters>@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/eth-json-rpc-filters>async-mutex": { "globals": { "setTimeout": true @@ -1011,11 +968,18 @@ "setTimeout": true }, "packages": { + "@metamask/eth-json-rpc-middleware>@metamask/json-rpc-engine": true, "@metamask/eth-json-rpc-middleware>@metamask/rpc-errors": true, "@metamask/eth-json-rpc-middleware>klona": true, "@metamask/eth-json-rpc-middleware>safe-stable-stringify": true, "@metamask/eth-sig-util": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, + "@metamask/utils": true + } + }, + "@metamask/eth-json-rpc-middleware>@metamask/json-rpc-engine": { + "packages": { + "@metamask/eth-json-rpc-middleware>@metamask/rpc-errors": true, + "@metamask/safe-event-emitter": true, "@metamask/utils": true } }, @@ -1437,6 +1401,49 @@ "jest-canvas-mock>moo-color>color-name": true } }, + "@metamask/json-rpc-engine": { + "packages": { + "@metamask/json-rpc-engine>@metamask/rpc-errors": true, + "@metamask/json-rpc-engine>@metamask/utils": true, + "@metamask/safe-event-emitter": true + } + }, + "@metamask/json-rpc-engine>@metamask/rpc-errors": { + "packages": { + "@metamask/json-rpc-engine>@metamask/rpc-errors>@metamask/utils": true, + "@metamask/rpc-errors>fast-safe-stringify": true + } + }, + "@metamask/json-rpc-engine>@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/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/keyring-api": { "globals": { "URL": true @@ -1636,10 +1643,10 @@ "@metamask/network-controller>@metamask/eth-json-rpc-infura": true, "@metamask/network-controller>@metamask/eth-json-rpc-middleware": true, "@metamask/network-controller>@metamask/eth-json-rpc-provider": true, + "@metamask/network-controller>@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/rpc-errors": true, "@metamask/network-controller>@metamask/swappable-obj-proxy": true, "@metamask/network-controller>reselect": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, "@metamask/utils": true, "browserify>assert": true, "browserify>util": true, @@ -1680,8 +1687,8 @@ "setTimeout": true }, "packages": { + "@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/eth-json-rpc-provider": true, - "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/rpc-errors": true, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/utils": true, "node-fetch": true @@ -1689,14 +1696,7 @@ }, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/eth-json-rpc-provider": { "packages": { - "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/json-rpc-engine": true, - "@metamask/safe-event-emitter": true - } - }, - "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/json-rpc-engine": { - "packages": { - "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/rpc-errors": true, - "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/utils": true, + "@metamask/json-rpc-engine": true, "@metamask/safe-event-emitter": true } }, @@ -1747,8 +1747,8 @@ "@metamask/eth-json-rpc-middleware>safe-stable-stringify": true, "@metamask/eth-sig-util": true, "@metamask/network-controller>@metamask/eth-json-rpc-middleware>@metamask/utils": true, + "@metamask/network-controller>@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/rpc-errors": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, "bn.js": true, "pify": true } @@ -1770,18 +1770,32 @@ }, "@metamask/network-controller>@metamask/eth-json-rpc-provider": { "packages": { + "@metamask/network-controller>@metamask/eth-json-rpc-provider>@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/eth-json-rpc-provider>@metamask/rpc-errors": true, "@metamask/safe-event-emitter": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, "uuid": true } }, + "@metamask/network-controller>@metamask/eth-json-rpc-provider>@metamask/json-rpc-engine": { + "packages": { + "@metamask/network-controller>@metamask/eth-json-rpc-provider>@metamask/rpc-errors": true, + "@metamask/safe-event-emitter": true, + "@metamask/utils": true + } + }, "@metamask/network-controller>@metamask/eth-json-rpc-provider>@metamask/rpc-errors": { "packages": { "@metamask/rpc-errors>fast-safe-stringify": true, "@metamask/utils": true } }, + "@metamask/network-controller>@metamask/json-rpc-engine": { + "packages": { + "@metamask/network-controller>@metamask/rpc-errors": true, + "@metamask/safe-event-emitter": true, + "@metamask/utils": true + } + }, "@metamask/network-controller>@metamask/rpc-errors": { "packages": { "@metamask/rpc-errors>fast-safe-stringify": true, @@ -1996,10 +2010,10 @@ "packages": { "@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/permission-controller>nanoid": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, "deep-freeze-strict": true, "immer": true } @@ -2012,6 +2026,28 @@ "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, @@ -2239,10 +2275,10 @@ "@metamask/queued-request-controller": { "packages": { "@metamask/queued-request-controller>@metamask/base-controller": true, + "@metamask/queued-request-controller>@metamask/json-rpc-engine": true, "@metamask/queued-request-controller>@metamask/rpc-errors": true, "@metamask/queued-request-controller>@metamask/utils": true, - "@metamask/selected-network-controller": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true + "@metamask/selected-network-controller": true } }, "@metamask/queued-request-controller>@metamask/base-controller": { @@ -2253,6 +2289,28 @@ "immer": true } }, + "@metamask/queued-request-controller>@metamask/json-rpc-engine": { + "packages": { + "@metamask/queued-request-controller>@metamask/json-rpc-engine>@metamask/utils": true, + "@metamask/queued-request-controller>@metamask/rpc-errors": true, + "@metamask/safe-event-emitter": true + } + }, + "@metamask/queued-request-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/queued-request-controller>@metamask/rpc-errors": { "packages": { "@metamask/queued-request-controller>@metamask/rpc-errors>@metamask/utils": true, @@ -2678,13 +2736,7 @@ "@metamask/snaps-controllers>@metamask/json-rpc-engine": { "packages": { "@metamask/safe-event-emitter": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/rpc-errors": true, - "@metamask/utils": true - } - }, - "@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/rpc-errors": { - "packages": { - "@metamask/rpc-errors>fast-safe-stringify": true, + "@metamask/snaps-controllers>@metamask/rpc-errors": true, "@metamask/utils": true } }, @@ -2793,8 +2845,8 @@ }, "packages": { "@metamask/controller-utils": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, "@metamask/snaps-rpc-methods>@metamask/permission-controller>@metamask/base-controller": true, + "@metamask/snaps-rpc-methods>@metamask/permission-controller>@metamask/json-rpc-engine": true, "@metamask/snaps-rpc-methods>@metamask/permission-controller>nanoid": true, "@metamask/snaps-rpc-methods>@metamask/rpc-errors": true, "@metamask/utils": true, @@ -2810,6 +2862,13 @@ "immer": true } }, + "@metamask/snaps-rpc-methods>@metamask/permission-controller>@metamask/json-rpc-engine": { + "packages": { + "@metamask/safe-event-emitter": true, + "@metamask/snaps-rpc-methods>@metamask/rpc-errors": true, + "@metamask/utils": true + } + }, "@metamask/snaps-rpc-methods>@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -2895,8 +2954,8 @@ }, "packages": { "@metamask/controller-utils": true, - "@metamask/snaps-controllers>@metamask/json-rpc-engine": true, "@metamask/snaps-utils>@metamask/base-controller": true, + "@metamask/snaps-utils>@metamask/permission-controller>@metamask/json-rpc-engine": true, "@metamask/snaps-utils>@metamask/permission-controller>nanoid": true, "@metamask/snaps-utils>@metamask/rpc-errors": true, "@metamask/utils": true, @@ -2904,6 +2963,13 @@ "immer": true } }, + "@metamask/snaps-utils>@metamask/permission-controller>@metamask/json-rpc-engine": { + "packages": { + "@metamask/safe-event-emitter": true, + "@metamask/snaps-utils>@metamask/rpc-errors": true, + "@metamask/utils": true + } + }, "@metamask/snaps-utils>@metamask/permission-controller>nanoid": { "globals": { "crypto.getRandomValues": true @@ -4766,25 +4832,6 @@ "stream-http": true } }, - "json-rpc-engine": { - "packages": { - "json-rpc-engine>@metamask/safe-event-emitter": true, - "json-rpc-engine>eth-rpc-errors": true - } - }, - "json-rpc-engine>@metamask/safe-event-emitter": { - "globals": { - "setTimeout": true - }, - "packages": { - "webpack>events": true - } - }, - "json-rpc-engine>eth-rpc-errors": { - "packages": { - "@metamask/rpc-errors>fast-safe-stringify": true - } - }, "json-rpc-middleware-stream": { "globals": { "console.warn": true, From e73cb364aedfa2dad449e5868856d4e7592cec96 Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Fri, 31 May 2024 05:38:52 +0000 Subject: [PATCH 06/16] chore: fix test --- .../lib/rpc-method-middleware/createMethodMiddleware.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/scripts/lib/rpc-method-middleware/createMethodMiddleware.test.js b/app/scripts/lib/rpc-method-middleware/createMethodMiddleware.test.js index 491d62b33b7b..6053f472e05c 100644 --- a/app/scripts/lib/rpc-method-middleware/createMethodMiddleware.test.js +++ b/app/scripts/lib/rpc-method-middleware/createMethodMiddleware.test.js @@ -140,7 +140,7 @@ describe.each([ assertIsJsonRpcFailure(response); expect(response.error.message).toBe('Internal JSON-RPC error.'); - expect(response.error.cause.message).toBe('test error'); + expect(response.error.data.cause.message).toBe('test error'); }); it('should handle errors thrown by the implementation', async () => { @@ -157,7 +157,7 @@ describe.each([ assertIsJsonRpcFailure(response); expect(response.error.message).toBe('Internal JSON-RPC error.'); - expect(response.error.cause.message).toBe('test error'); + expect(response.error.data.cause.message).toBe('test error'); }); it('should handle non-errors thrown by the implementation', async () => { From 188ad272ea723ceea5529b1bc60b754c30c247f0 Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Fri, 31 May 2024 06:28:54 +0000 Subject: [PATCH 07/16] chore: fix createUnsupportedMethodMiddleware return type --- .../createUnsupportedMethodMiddleware.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/scripts/lib/rpc-method-middleware/createUnsupportedMethodMiddleware.ts b/app/scripts/lib/rpc-method-middleware/createUnsupportedMethodMiddleware.ts index ac8c48c6df9d..c96201041d36 100644 --- a/app/scripts/lib/rpc-method-middleware/createUnsupportedMethodMiddleware.ts +++ b/app/scripts/lib/rpc-method-middleware/createUnsupportedMethodMiddleware.ts @@ -1,4 +1,5 @@ import type { JsonRpcMiddleware } from '@metamask/json-rpc-engine'; +import type { JsonRpcParams } from '@metamask/utils'; import { rpcErrors } from '@metamask/rpc-errors'; import { UNSUPPORTED_RPC_METHODS } from '../../../../shared/constants/network'; @@ -7,8 +8,8 @@ import { UNSUPPORTED_RPC_METHODS } from '../../../../shared/constants/network'; * appropriate error. */ export function createUnsupportedMethodMiddleware(): JsonRpcMiddleware< - unknown, - void + JsonRpcParams, + null > { return async function unsupportedMethodMiddleware(req, _res, next, end) { if ((UNSUPPORTED_RPC_METHODS as Set).has(req.method)) { From 2908fddb1fa6b76b35d2d722d5792a8d6a89cc80 Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Wed, 16 Oct 2024 23:25:04 +0000 Subject: [PATCH 08/16] deps: @metamask/json-rpc-engine@^7.3.3->^10.0.0 --- package.json | 2 +- yarn.lock | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index fc34c2f9c15f..26c633a6b2dc 100644 --- a/package.json +++ b/package.json @@ -323,7 +323,7 @@ "@metamask/ethjs-query": "^0.7.1", "@metamask/gas-fee-controller": "^18.0.0", "@metamask/jazzicon": "^2.0.0", - "@metamask/json-rpc-engine": "^7.3.3", + "@metamask/json-rpc-engine": "^10.0.0", "@metamask/keyring-api": "^8.1.3", "@metamask/keyring-controller": "^17.2.2", "@metamask/logging-controller": "^6.0.0", diff --git a/yarn.lock b/yarn.lock index 2e639921a680..b7c2dfa5ac0a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5581,7 +5581,18 @@ __metadata: languageName: node linkType: hard -"@metamask/json-rpc-engine@npm:^7.1.0, @metamask/json-rpc-engine@npm:^7.1.1, @metamask/json-rpc-engine@npm:^7.3.2, @metamask/json-rpc-engine@npm:^7.3.3": +"@metamask/json-rpc-engine@npm:^10.0.0": + version: 10.0.0 + resolution: "@metamask/json-rpc-engine@npm:10.0.0" + dependencies: + "@metamask/rpc-errors": "npm:^7.0.0" + "@metamask/safe-event-emitter": "npm:^3.0.0" + "@metamask/utils": "npm:^9.1.0" + checksum: 10/2c401a4a64392aeb11c4f7ca8d7b458ba1106cff1e0b3dba8b3e0cc90e82f8c55ac2dc9fdfcd914b289e3298fb726d637cf21382336dde2c207cf76129ce5eab + languageName: node + linkType: hard + +"@metamask/json-rpc-engine@npm:^7.1.0, @metamask/json-rpc-engine@npm:^7.1.1, @metamask/json-rpc-engine@npm:^7.3.2": version: 7.3.3 resolution: "@metamask/json-rpc-engine@npm:7.3.3" dependencies: @@ -26111,7 +26122,7 @@ __metadata: "@metamask/forwarder": "npm:^1.1.0" "@metamask/gas-fee-controller": "npm:^18.0.0" "@metamask/jazzicon": "npm:^2.0.0" - "@metamask/json-rpc-engine": "npm:^7.3.3" + "@metamask/json-rpc-engine": "npm:^10.0.0" "@metamask/keyring-api": "npm:^8.1.3" "@metamask/keyring-controller": "npm:^17.2.2" "@metamask/logging-controller": "npm:^6.0.0" From ee425a761f493992a1376a57a97f98947be9e700 Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Wed, 16 Oct 2024 23:39:17 +0000 Subject: [PATCH 09/16] chore: update lavamoat policies --- lavamoat/browserify/beta/policy.json | 98 +++++++++++++++------------ lavamoat/browserify/flask/policy.json | 98 +++++++++++++++------------ lavamoat/browserify/main/policy.json | 98 +++++++++++++++------------ lavamoat/browserify/mmi/policy.json | 98 +++++++++++++++------------ 4 files changed, 224 insertions(+), 168 deletions(-) diff --git a/lavamoat/browserify/beta/policy.json b/lavamoat/browserify/beta/policy.json index 2d2289e97931..0537447e2860 100644 --- a/lavamoat/browserify/beta/policy.json +++ b/lavamoat/browserify/beta/policy.json @@ -849,8 +849,8 @@ }, "packages": { "@metamask/eth-json-rpc-filters>@metamask/eth-query": true, + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine": true, "@metamask/eth-json-rpc-filters>async-mutex": true, - "@metamask/json-rpc-engine": true, "@metamask/safe-event-emitter": true, "pify": true } @@ -861,6 +861,49 @@ "watchify>xtend": true } }, + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine": { + "packages": { + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/rpc-errors": true, + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/utils": true, + "@metamask/safe-event-emitter": true + } + }, + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/rpc-errors": { + "packages": { + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/rpc-errors>@metamask/utils": true, + "@metamask/rpc-errors>fast-safe-stringify": true + } + }, + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@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/eth-json-rpc-filters>@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/eth-json-rpc-filters>async-mutex": { "globals": { "setTimeout": true @@ -1311,45 +1354,9 @@ }, "@metamask/json-rpc-engine": { "packages": { - "@metamask/json-rpc-engine>@metamask/rpc-errors": true, - "@metamask/json-rpc-engine>@metamask/utils": true, - "@metamask/safe-event-emitter": true - } - }, - "@metamask/json-rpc-engine>@metamask/rpc-errors": { - "packages": { - "@metamask/json-rpc-engine>@metamask/rpc-errors>@metamask/utils": true, - "@metamask/rpc-errors>fast-safe-stringify": true - } - }, - "@metamask/json-rpc-engine>@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/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/rpc-errors": true, + "@metamask/safe-event-emitter": true, + "@metamask/utils": true } }, "@metamask/keyring-api": { @@ -1595,8 +1602,8 @@ "setTimeout": true }, "packages": { - "@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/eth-json-rpc-provider": true, + "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/rpc-errors": true, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/utils": true, "node-fetch": true @@ -1604,7 +1611,14 @@ }, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/eth-json-rpc-provider": { "packages": { - "@metamask/json-rpc-engine": true, + "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/json-rpc-engine": true, + "@metamask/safe-event-emitter": true + } + }, + "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/json-rpc-engine": { + "packages": { + "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/rpc-errors": true, + "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/utils": true, "@metamask/safe-event-emitter": true } }, diff --git a/lavamoat/browserify/flask/policy.json b/lavamoat/browserify/flask/policy.json index 2d2289e97931..0537447e2860 100644 --- a/lavamoat/browserify/flask/policy.json +++ b/lavamoat/browserify/flask/policy.json @@ -849,8 +849,8 @@ }, "packages": { "@metamask/eth-json-rpc-filters>@metamask/eth-query": true, + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine": true, "@metamask/eth-json-rpc-filters>async-mutex": true, - "@metamask/json-rpc-engine": true, "@metamask/safe-event-emitter": true, "pify": true } @@ -861,6 +861,49 @@ "watchify>xtend": true } }, + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine": { + "packages": { + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/rpc-errors": true, + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/utils": true, + "@metamask/safe-event-emitter": true + } + }, + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/rpc-errors": { + "packages": { + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/rpc-errors>@metamask/utils": true, + "@metamask/rpc-errors>fast-safe-stringify": true + } + }, + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@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/eth-json-rpc-filters>@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/eth-json-rpc-filters>async-mutex": { "globals": { "setTimeout": true @@ -1311,45 +1354,9 @@ }, "@metamask/json-rpc-engine": { "packages": { - "@metamask/json-rpc-engine>@metamask/rpc-errors": true, - "@metamask/json-rpc-engine>@metamask/utils": true, - "@metamask/safe-event-emitter": true - } - }, - "@metamask/json-rpc-engine>@metamask/rpc-errors": { - "packages": { - "@metamask/json-rpc-engine>@metamask/rpc-errors>@metamask/utils": true, - "@metamask/rpc-errors>fast-safe-stringify": true - } - }, - "@metamask/json-rpc-engine>@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/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/rpc-errors": true, + "@metamask/safe-event-emitter": true, + "@metamask/utils": true } }, "@metamask/keyring-api": { @@ -1595,8 +1602,8 @@ "setTimeout": true }, "packages": { - "@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/eth-json-rpc-provider": true, + "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/rpc-errors": true, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/utils": true, "node-fetch": true @@ -1604,7 +1611,14 @@ }, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/eth-json-rpc-provider": { "packages": { - "@metamask/json-rpc-engine": true, + "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/json-rpc-engine": true, + "@metamask/safe-event-emitter": true + } + }, + "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/json-rpc-engine": { + "packages": { + "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/rpc-errors": true, + "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/utils": true, "@metamask/safe-event-emitter": true } }, diff --git a/lavamoat/browserify/main/policy.json b/lavamoat/browserify/main/policy.json index 2d2289e97931..0537447e2860 100644 --- a/lavamoat/browserify/main/policy.json +++ b/lavamoat/browserify/main/policy.json @@ -849,8 +849,8 @@ }, "packages": { "@metamask/eth-json-rpc-filters>@metamask/eth-query": true, + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine": true, "@metamask/eth-json-rpc-filters>async-mutex": true, - "@metamask/json-rpc-engine": true, "@metamask/safe-event-emitter": true, "pify": true } @@ -861,6 +861,49 @@ "watchify>xtend": true } }, + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine": { + "packages": { + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/rpc-errors": true, + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/utils": true, + "@metamask/safe-event-emitter": true + } + }, + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/rpc-errors": { + "packages": { + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/rpc-errors>@metamask/utils": true, + "@metamask/rpc-errors>fast-safe-stringify": true + } + }, + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@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/eth-json-rpc-filters>@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/eth-json-rpc-filters>async-mutex": { "globals": { "setTimeout": true @@ -1311,45 +1354,9 @@ }, "@metamask/json-rpc-engine": { "packages": { - "@metamask/json-rpc-engine>@metamask/rpc-errors": true, - "@metamask/json-rpc-engine>@metamask/utils": true, - "@metamask/safe-event-emitter": true - } - }, - "@metamask/json-rpc-engine>@metamask/rpc-errors": { - "packages": { - "@metamask/json-rpc-engine>@metamask/rpc-errors>@metamask/utils": true, - "@metamask/rpc-errors>fast-safe-stringify": true - } - }, - "@metamask/json-rpc-engine>@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/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/rpc-errors": true, + "@metamask/safe-event-emitter": true, + "@metamask/utils": true } }, "@metamask/keyring-api": { @@ -1595,8 +1602,8 @@ "setTimeout": true }, "packages": { - "@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/eth-json-rpc-provider": true, + "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/rpc-errors": true, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/utils": true, "node-fetch": true @@ -1604,7 +1611,14 @@ }, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/eth-json-rpc-provider": { "packages": { - "@metamask/json-rpc-engine": true, + "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/json-rpc-engine": true, + "@metamask/safe-event-emitter": true + } + }, + "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/json-rpc-engine": { + "packages": { + "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/rpc-errors": true, + "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/utils": true, "@metamask/safe-event-emitter": true } }, diff --git a/lavamoat/browserify/mmi/policy.json b/lavamoat/browserify/mmi/policy.json index 86eb589ad8d6..96e440ce71a6 100644 --- a/lavamoat/browserify/mmi/policy.json +++ b/lavamoat/browserify/mmi/policy.json @@ -941,8 +941,8 @@ }, "packages": { "@metamask/eth-json-rpc-filters>@metamask/eth-query": true, + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine": true, "@metamask/eth-json-rpc-filters>async-mutex": true, - "@metamask/json-rpc-engine": true, "@metamask/safe-event-emitter": true, "pify": true } @@ -953,6 +953,49 @@ "watchify>xtend": true } }, + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine": { + "packages": { + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/rpc-errors": true, + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/utils": true, + "@metamask/safe-event-emitter": true + } + }, + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/rpc-errors": { + "packages": { + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@metamask/rpc-errors>@metamask/utils": true, + "@metamask/rpc-errors>fast-safe-stringify": true + } + }, + "@metamask/eth-json-rpc-filters>@metamask/json-rpc-engine>@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/eth-json-rpc-filters>@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/eth-json-rpc-filters>async-mutex": { "globals": { "setTimeout": true @@ -1403,45 +1446,9 @@ }, "@metamask/json-rpc-engine": { "packages": { - "@metamask/json-rpc-engine>@metamask/rpc-errors": true, - "@metamask/json-rpc-engine>@metamask/utils": true, - "@metamask/safe-event-emitter": true - } - }, - "@metamask/json-rpc-engine>@metamask/rpc-errors": { - "packages": { - "@metamask/json-rpc-engine>@metamask/rpc-errors>@metamask/utils": true, - "@metamask/rpc-errors>fast-safe-stringify": true - } - }, - "@metamask/json-rpc-engine>@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/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/rpc-errors": true, + "@metamask/safe-event-emitter": true, + "@metamask/utils": true } }, "@metamask/keyring-api": { @@ -1687,8 +1694,8 @@ "setTimeout": true }, "packages": { - "@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/eth-json-rpc-provider": true, + "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/json-rpc-engine": true, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/rpc-errors": true, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/utils": true, "node-fetch": true @@ -1696,7 +1703,14 @@ }, "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/eth-json-rpc-provider": { "packages": { - "@metamask/json-rpc-engine": true, + "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/json-rpc-engine": true, + "@metamask/safe-event-emitter": true + } + }, + "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/json-rpc-engine": { + "packages": { + "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/rpc-errors": true, + "@metamask/network-controller>@metamask/eth-json-rpc-infura>@metamask/utils": true, "@metamask/safe-event-emitter": true } }, From cdee99e7462958d6f46ee7b659a7706c246075e8 Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Thu, 17 Oct 2024 00:22:51 +0000 Subject: [PATCH 10/16] chore: update test expected error messages --- .../lib/rpc-method-middleware/createMethodMiddleware.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/scripts/lib/rpc-method-middleware/createMethodMiddleware.test.js b/app/scripts/lib/rpc-method-middleware/createMethodMiddleware.test.js index 6053f472e05c..48ea5ae90d58 100644 --- a/app/scripts/lib/rpc-method-middleware/createMethodMiddleware.test.js +++ b/app/scripts/lib/rpc-method-middleware/createMethodMiddleware.test.js @@ -139,7 +139,7 @@ describe.each([ }); assertIsJsonRpcFailure(response); - expect(response.error.message).toBe('Internal JSON-RPC error.'); + expect(response.error.message).toBe('test error'); expect(response.error.data.cause.message).toBe('test error'); }); @@ -156,7 +156,7 @@ describe.each([ }); assertIsJsonRpcFailure(response); - expect(response.error.message).toBe('Internal JSON-RPC error.'); + expect(response.error.message).toBe('test error'); expect(response.error.data.cause.message).toBe('test error'); }); From 356da303c87aafb53f4ad547c9ed6ce1a4cb5280 Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Thu, 17 Oct 2024 00:38:34 +0000 Subject: [PATCH 11/16] fix legacy import --- app/scripts/controllers/preferences-controller.ts | 2 +- .../lib/tx-verification/tx-verification-middleware.ts | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/scripts/controllers/preferences-controller.ts b/app/scripts/controllers/preferences-controller.ts index a7ede69bb26c..1c950a026061 100644 --- a/app/scripts/controllers/preferences-controller.ts +++ b/app/scripts/controllers/preferences-controller.ts @@ -13,7 +13,7 @@ import { ControllerStateChangeEvent, RestrictedControllerMessenger, } from '@metamask/base-controller'; -import { Json } from 'json-rpc-engine'; +import { Json } from '@metamask/json-rpc-engine'; import { NetworkControllerGetStateAction } from '@metamask/network-controller'; import { ETHERSCAN_SUPPORTED_CHAIN_IDS, diff --git a/app/scripts/lib/tx-verification/tx-verification-middleware.ts b/app/scripts/lib/tx-verification/tx-verification-middleware.ts index ff3b418eec60..67ce1ee8cc47 100644 --- a/app/scripts/lib/tx-verification/tx-verification-middleware.ts +++ b/app/scripts/lib/tx-verification/tx-verification-middleware.ts @@ -2,14 +2,18 @@ import { hashMessage } from '@ethersproject/hash'; import { verifyMessage } from '@ethersproject/wallet'; import type { NetworkController } from '@metamask/network-controller'; import { rpcErrors } from '@metamask/rpc-errors'; -import type { Json, JsonRpcParams, Hex } from '@metamask/utils'; -import { hasProperty, isObject } from '@metamask/utils'; +import type { + Json, + JsonRpcParams, + Hex, + JsonRpcResponse, +} from '@metamask/utils'; +import { hasProperty, isObject, JsonRpcRequest } from '@metamask/utils'; import type { JsonRpcResponse, JsonRpcEngineEndCallback, JsonRpcEngineNextCallback, } from '@metamask/json-rpc-engine'; -import { JsonRpcRequest } from '@metamask/json-rpc-engine'; import { EXPERIENCES_TO_VERIFY, getExperience, From 0bf69b656fe0e69b370fdf9f25863fb00126fd06 Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Thu, 17 Oct 2024 00:43:11 +0000 Subject: [PATCH 12/16] fix JsonRpcRequest,JsonRpcResponse imports --- .../handlers/institutional/mmi-authenticate.js | 4 ++-- .../handlers/institutional/mmi-check-if-token-is-present.js | 4 ++-- .../handlers/institutional/mmi-open-add-hardware-wallet.js | 4 ++-- .../handlers/institutional/mmi-portfolio.js | 4 ++-- .../handlers/institutional/mmi-set-account-and-network.js | 4 ++-- .../handlers/institutional/mmi-supported.js | 4 ++-- .../lib/rpc-method-middleware/handlers/request-accounts.js | 4 ++-- .../lib/rpc-method-middleware/handlers/send-metadata.js | 4 ++-- app/scripts/lib/rpc-method-middleware/handlers/watch-asset.js | 4 ++-- app/scripts/lib/tx-verification/tx-verification-middleware.ts | 3 +-- 10 files changed, 19 insertions(+), 20 deletions(-) diff --git a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-authenticate.js b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-authenticate.js index 57d9e8e53c52..e30332651c8c 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-authenticate.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-authenticate.js @@ -21,8 +21,8 @@ export default mmiAuthenticate; */ /** - * @param {import('@metamask/json-rpc-engine').JsonRpcRequest} req - The JSON-RPC request object. - * @param {import('@metamask/json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. + * @param {import('@metamask/utils').JsonRpcRequest} req - The JSON-RPC request object. + * @param {import('@metamask/utils').JsonRpcResponse} res - The JSON-RPC response object. * @param {Function} _next - The json-rpc-engine 'next' callback. * @param {Function} end - The json-rpc-engine 'end' callback. * @param {WatchAssetOptions} options diff --git a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-check-if-token-is-present.js b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-check-if-token-is-present.js index f45772d6ad7d..428997bff70c 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-check-if-token-is-present.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-check-if-token-is-present.js @@ -23,8 +23,8 @@ export default mmiAuthenticate; */ /** - * @param {import('@metamask/json-rpc-engine').JsonRpcRequest} req - The JSON-RPC request object. - * @param {import('@metamask/json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. + * @param {import('@metamask/utils').JsonRpcRequest} req - The JSON-RPC request object. + * @param {import('@metamask/utils').JsonRpcResponse} res - The JSON-RPC response object. * @param {Function} _next - The json-rpc-engine 'next' callback. * @param {Function} end - The json-rpc-engine 'end' callback. * @param options0 diff --git a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-open-add-hardware-wallet.js b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-open-add-hardware-wallet.js index b70d13a88f2f..7e685e1754a1 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-open-add-hardware-wallet.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-open-add-hardware-wallet.js @@ -16,8 +16,8 @@ export default mmiOpenAddHardwareWallet; */ /** - * @param {import('@metamask/json-rpc-engine').JsonRpcRequest} req - The JSON-RPC request object. - * @param {import('@metamask/json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. + * @param {import('@metamask/utils').JsonRpcRequest} req - The JSON-RPC request object. + * @param {import('@metamask/utils').JsonRpcResponse} res - The JSON-RPC response object. * @param {Function} _next - The json-rpc-engine 'next' callback. * @param {Function} end - The json-rpc-engine 'end' callback. * @param {WatchAssetOptions} options diff --git a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-portfolio.js b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-portfolio.js index e637ad419244..7f76d3239afb 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-portfolio.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-portfolio.js @@ -22,8 +22,8 @@ export default mmiPortfolio; */ /** - * @param {import('@metamask/json-rpc-engine').JsonRpcRequest} req - The JSON-RPC request object. - * @param {import('@metamask/json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. + * @param {import('@metamask/utils').JsonRpcRequest} req - The JSON-RPC request object. + * @param {import('@metamask/utils').JsonRpcResponse} res - The JSON-RPC response object. * @param {Function} _next - The json-rpc-engine 'next' callback. * @param {Function} end - The json-rpc-engine 'end' callback. * @param {WatchAssetOptions} options diff --git a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-set-account-and-network.js b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-set-account-and-network.js index 36e4add51cdf..46754e144fab 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-set-account-and-network.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-set-account-and-network.js @@ -23,8 +23,8 @@ export default mmiSetAccountAndNetwork; */ /** - * @param {import('@metamask/json-rpc-engine').JsonRpcRequest} req - The JSON-RPC request object. - * @param {import('@metamask/json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. + * @param {import('@metamask/utils').JsonRpcRequest} req - The JSON-RPC request object. + * @param {import('@metamask/utils').JsonRpcResponse} res - The JSON-RPC response object. * @param {Function} _next - The json-rpc-engine 'next' callback. * @param {Function} end - The json-rpc-engine 'end' callback. * @param {WatchAssetOptions} options diff --git a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-supported.js b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-supported.js index a0d87cd7341d..e72a1aebf830 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-supported.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/institutional/mmi-supported.js @@ -19,8 +19,8 @@ export default mmiSupported; */ /** - * @param {import('@metamask/json-rpc-engine').JsonRpcRequest} _req - The JSON-RPC request object. - * @param {import('@metamask/json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. + * @param {import('@metamask/utils').JsonRpcRequest} _req - The JSON-RPC request object. + * @param {import('@metamask/utils').JsonRpcResponse} res - The JSON-RPC response object. * @param {Function} _next - The json-rpc-engine 'next' callback. * @param {Function} end - The json-rpc-engine 'end' callback. */ diff --git a/app/scripts/lib/rpc-method-middleware/handlers/request-accounts.js b/app/scripts/lib/rpc-method-middleware/handlers/request-accounts.js index d5f6d110568d..68b52ea75549 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/request-accounts.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/request-accounts.js @@ -48,8 +48,8 @@ const locks = new Set(); /** * - * @param {import('@metamask/json-rpc-engine').JsonRpcRequest} _req - The JSON-RPC request object. - * @param {import('@metamask/json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. + * @param {import('@metamask/utils').JsonRpcRequest} _req - The JSON-RPC request object. + * @param {import('@metamask/utils').JsonRpcResponse} res - The JSON-RPC response object. * @param {Function} _next - The json-rpc-engine 'next' callback. * @param {Function} end - The json-rpc-engine 'end' callback. * @param {RequestEthereumAccountsOptions} options - The RPC method hooks. diff --git a/app/scripts/lib/rpc-method-middleware/handlers/send-metadata.js b/app/scripts/lib/rpc-method-middleware/handlers/send-metadata.js index 03253f6dc7b0..5dcfdf274fb6 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/send-metadata.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/send-metadata.js @@ -25,8 +25,8 @@ export default sendMetadata; */ /** - * @param {import('@metamask/json-rpc-engine').JsonRpcRequest} req - The JSON-RPC request object. - * @param {import('@metamask/json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. + * @param {import('@metamask/utils').JsonRpcRequest} req - The JSON-RPC request object. + * @param {import('@metamask/utils').JsonRpcResponse} res - The JSON-RPC response object. * @param {Function} _next - The json-rpc-engine 'next' callback. * @param {Function} end - The json-rpc-engine 'end' callback. * @param {SendMetadataOptions} options diff --git a/app/scripts/lib/rpc-method-middleware/handlers/watch-asset.js b/app/scripts/lib/rpc-method-middleware/handlers/watch-asset.js index 129005dacf33..2f3475f7df71 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/watch-asset.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/watch-asset.js @@ -23,8 +23,8 @@ export default watchAsset; */ /** - * @param {import('@metamask/json-rpc-engine').JsonRpcRequest} req - The JSON-RPC request object. - * @param {import('@metamask/json-rpc-engine').JsonRpcResponse} res - The JSON-RPC response object. + * @param {import('@metamask/utils').JsonRpcRequest} req - The JSON-RPC request object. + * @param {import('@metamask/utils').JsonRpcResponse} res - The JSON-RPC response object. * @param {Function} _next - The json-rpc-engine 'next' callback. * @param {Function} end - The json-rpc-engine 'end' callback. * @param {WatchAssetOptions} options diff --git a/app/scripts/lib/tx-verification/tx-verification-middleware.ts b/app/scripts/lib/tx-verification/tx-verification-middleware.ts index 67ce1ee8cc47..7abdf73e3637 100644 --- a/app/scripts/lib/tx-verification/tx-verification-middleware.ts +++ b/app/scripts/lib/tx-verification/tx-verification-middleware.ts @@ -5,12 +5,11 @@ import { rpcErrors } from '@metamask/rpc-errors'; import type { Json, JsonRpcParams, - Hex, JsonRpcResponse, + Hex, } from '@metamask/utils'; import { hasProperty, isObject, JsonRpcRequest } from '@metamask/utils'; import type { - JsonRpcResponse, JsonRpcEngineEndCallback, JsonRpcEngineNextCallback, } from '@metamask/json-rpc-engine'; From 24d4f7d266e30720618ab82e41011938f1ae979d Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Thu, 17 Oct 2024 01:42:49 +0000 Subject: [PATCH 13/16] chore: lint:fix --- app/scripts/controllers/preferences-controller.ts | 3 +-- ...reateEvmMethodsToNonEvmAccountReqFilterMiddleware.test.ts | 3 +-- .../createEvmMethodsToNonEvmAccountReqFilterMiddleware.ts | 5 +++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/scripts/controllers/preferences-controller.ts b/app/scripts/controllers/preferences-controller.ts index 1c950a026061..536ec33b34eb 100644 --- a/app/scripts/controllers/preferences-controller.ts +++ b/app/scripts/controllers/preferences-controller.ts @@ -6,14 +6,13 @@ import { AccountsControllerSetSelectedAccountAction, AccountsControllerState, } from '@metamask/accounts-controller'; -import { Hex } from '@metamask/utils'; +import { Hex, Json } from '@metamask/utils'; import { BaseController, ControllerGetStateAction, ControllerStateChangeEvent, RestrictedControllerMessenger, } from '@metamask/base-controller'; -import { Json } from '@metamask/json-rpc-engine'; import { NetworkControllerGetStateAction } from '@metamask/network-controller'; import { ETHERSCAN_SUPPORTED_CHAIN_IDS, diff --git a/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.test.ts b/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.test.ts index b6160a1d7a88..1f62a491b338 100644 --- a/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.test.ts +++ b/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.test.ts @@ -1,6 +1,5 @@ -import { jsonrpc2 } from '@metamask/utils'; +import { jsonrpc2, Json } from '@metamask/utils'; import { BtcAccountType, EthAccountType } from '@metamask/keyring-api'; -import { Json } from '@metamask/json-rpc-engine'; import createEvmMethodsToNonEvmAccountReqFilterMiddleware, { EvmMethodsToNonEvmAccountFilterMessenger, } from './createEvmMethodsToNonEvmAccountReqFilterMiddleware'; diff --git a/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.ts b/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.ts index 89edd402d97c..7e7abda5ce49 100644 --- a/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.ts +++ b/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.ts @@ -2,6 +2,7 @@ import { isEvmAccountType } from '@metamask/keyring-api'; import { RestrictedControllerMessenger } from '@metamask/base-controller'; import { AccountsControllerGetSelectedAccountAction } from '@metamask/accounts-controller'; import { JsonRpcMiddleware } from '@metamask/json-rpc-engine'; +import type { Json, JsonRpcParams } from '@metamask/utils'; import { RestrictedEthMethods } from '../../../shared/constants/permissions'; import { unrestrictedEthSigningMethods } from '../controllers/permissions'; @@ -32,7 +33,7 @@ export default function createEvmMethodsToNonEvmAccountReqFilterMiddleware({ messenger, }: { messenger: EvmMethodsToNonEvmAccountFilterMessenger; -}): JsonRpcMiddleware { +}): JsonRpcMiddleware { return function filterEvmRequestToNonEvmAccountsMiddleware( req, _res, @@ -75,7 +76,7 @@ export default function createEvmMethodsToNonEvmAccountReqFilterMiddleware({ const isWalletRequestPermission = req.method === 'wallet_requestPermissions'; if (isWalletRequestPermission && req?.params && Array.isArray(req.params)) { - const permissionsMethodRequest = Object.keys(req.params[0]); + const permissionsMethodRequest = Object.keys(req.params[0] as {}); const isEvmPermissionRequest = METHODS_TO_CHECK.some((method) => permissionsMethodRequest.includes(method), From 7bd49b7fef376e7242bda0790c5d95e17eae5aad Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Thu, 17 Oct 2024 01:50:03 +0000 Subject: [PATCH 14/16] fix: check for null/undefined param in wallet_requestPermissions request handling --- ...eateEvmMethodsToNonEvmAccountReqFilterMiddleware.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.ts b/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.ts index 7e7abda5ce49..cc912b5113a7 100644 --- a/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.ts +++ b/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.ts @@ -75,8 +75,14 @@ export default function createEvmMethodsToNonEvmAccountReqFilterMiddleware({ // TODO: Convert this to superstruct schema const isWalletRequestPermission = req.method === 'wallet_requestPermissions'; - if (isWalletRequestPermission && req?.params && Array.isArray(req.params)) { - const permissionsMethodRequest = Object.keys(req.params[0] as {}); + if ( + isWalletRequestPermission && + req?.params && + Array.isArray(req.params) && + req.params.length > 0 && + req.params[0] + ) { + const permissionsMethodRequest = Object.keys(req.params[0]); const isEvmPermissionRequest = METHODS_TO_CHECK.some((method) => permissionsMethodRequest.includes(method), From 40a0197cbc39e15946027354c643955c4af4b698 Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Thu, 17 Oct 2024 02:23:09 +0000 Subject: [PATCH 15/16] chore(test): json rpc request params is not optional --- ...ToNonEvmAccountReqFilterMiddleware.test.ts | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.test.ts b/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.test.ts index 1f62a491b338..7504b8a63d60 100644 --- a/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.test.ts +++ b/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.test.ts @@ -5,7 +5,7 @@ import createEvmMethodsToNonEvmAccountReqFilterMiddleware, { } from './createEvmMethodsToNonEvmAccountReqFilterMiddleware'; describe('createEvmMethodsToNonEvmAccountReqFilterMiddleware', () => { - const getMockRequest = (method: string, params?: Json) => ({ + const getMockRequest = (method: string, params: Json) => ({ jsonrpc: jsonrpc2, id: 1, method, @@ -19,71 +19,85 @@ describe('createEvmMethodsToNonEvmAccountReqFilterMiddleware', () => { { accountType: BtcAccountType.P2wpkh, method: 'eth_accounts', + params: [], calledNext: false, }, { accountType: BtcAccountType.P2wpkh, method: 'eth_sendRawTransaction', + params: [], calledNext: false, }, { accountType: BtcAccountType.P2wpkh, method: 'eth_sendTransaction', + params: [], calledNext: false, }, { accountType: BtcAccountType.P2wpkh, method: 'eth_signTypedData', + params: [], calledNext: false, }, { accountType: BtcAccountType.P2wpkh, method: 'eth_signTypedData_v1', + params: [], calledNext: false, }, { accountType: BtcAccountType.P2wpkh, method: 'eth_signTypedData_v3', + params: [], calledNext: false, }, { accountType: BtcAccountType.P2wpkh, method: 'eth_signTypedData_v4', + params: [], calledNext: false, }, { accountType: EthAccountType.Eoa, method: 'eth_accounts', + params: [], calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'eth_sendRawTransaction', + params: [], calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'eth_sendTransaction', + params: [], calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'eth_signTypedData', + params: [], calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'eth_signTypedData_v1', + params: [], calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'eth_signTypedData_v3', + params: [], calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'eth_signTypedData_v4', + params: [], calledNext: true, }, @@ -91,21 +105,25 @@ describe('createEvmMethodsToNonEvmAccountReqFilterMiddleware', () => { { accountType: BtcAccountType.P2wpkh, method: 'eth_blockNumber', + params: [], calledNext: true, }, { accountType: BtcAccountType.P2wpkh, method: 'eth_chainId', + params: [], calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'eth_blockNumber', + params: [], calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'eth_chainId', + params: [], calledNext: true, }, @@ -113,91 +131,109 @@ describe('createEvmMethodsToNonEvmAccountReqFilterMiddleware', () => { { accountType: BtcAccountType.P2wpkh, method: 'wallet_getSnaps', + params: [], calledNext: true, }, { accountType: BtcAccountType.P2wpkh, method: 'wallet_invokeSnap', + params: [], calledNext: true, }, { accountType: BtcAccountType.P2wpkh, method: 'wallet_requestSnaps', + params: [], calledNext: true, }, { accountType: BtcAccountType.P2wpkh, method: 'snap_getClientStatus', + params: [], calledNext: true, }, { accountType: BtcAccountType.P2wpkh, method: 'wallet_addEthereumChain', + params: [], calledNext: true, }, { accountType: BtcAccountType.P2wpkh, method: 'wallet_getPermissions', + params: [], calledNext: true, }, { accountType: BtcAccountType.P2wpkh, method: 'wallet_requestPermissions', + params: [], calledNext: true, }, { accountType: BtcAccountType.P2wpkh, method: 'wallet_revokePermissions', + params: [], calledNext: true, }, { accountType: BtcAccountType.P2wpkh, method: 'wallet_switchEthereumChain', + params: [], calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'wallet_getSnaps', + params: [], calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'wallet_invokeSnap', + params: [], calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'wallet_requestSnaps', + params: [], calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'snap_getClientStatus', + params: [], calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'wallet_addEthereumChain', + params: [], calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'wallet_getPermissions', + params: [], calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'wallet_requestPermissions', + params: [], calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'wallet_revokePermissions', + params: [], calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'wallet_switchEthereumChain', + params: [], calledNext: true, }, @@ -249,7 +285,7 @@ describe('createEvmMethodsToNonEvmAccountReqFilterMiddleware', () => { }: { accountType: EthAccountType | BtcAccountType; method: string; - params?: Json; + params: Json; calledNext: number; }) => { const filterFn = createEvmMethodsToNonEvmAccountReqFilterMiddleware({ From fd1494867acb15cf20268744e6f4f1559636c338 Mon Sep 17 00:00:00 2001 From: legobt <6wbvkn0j@anonaddy.me> Date: Thu, 17 Oct 2024 02:58:46 +0000 Subject: [PATCH 16/16] chore(test): json rpc request params can still be undefined --- ...ToNonEvmAccountReqFilterMiddleware.test.ts | 75 ++++++++++--------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.test.ts b/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.test.ts index 7504b8a63d60..063271a9984a 100644 --- a/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.test.ts +++ b/app/scripts/lib/createEvmMethodsToNonEvmAccountReqFilterMiddleware.test.ts @@ -1,5 +1,6 @@ import { jsonrpc2, Json } from '@metamask/utils'; import { BtcAccountType, EthAccountType } from '@metamask/keyring-api'; +import type { JsonRpcParams, JsonRpcRequest } from '@metamask/utils'; import createEvmMethodsToNonEvmAccountReqFilterMiddleware, { EvmMethodsToNonEvmAccountFilterMessenger, } from './createEvmMethodsToNonEvmAccountReqFilterMiddleware'; @@ -19,85 +20,85 @@ describe('createEvmMethodsToNonEvmAccountReqFilterMiddleware', () => { { accountType: BtcAccountType.P2wpkh, method: 'eth_accounts', - params: [], + params: undefined, calledNext: false, }, { accountType: BtcAccountType.P2wpkh, method: 'eth_sendRawTransaction', - params: [], + params: undefined, calledNext: false, }, { accountType: BtcAccountType.P2wpkh, method: 'eth_sendTransaction', - params: [], + params: undefined, calledNext: false, }, { accountType: BtcAccountType.P2wpkh, method: 'eth_signTypedData', - params: [], + params: undefined, calledNext: false, }, { accountType: BtcAccountType.P2wpkh, method: 'eth_signTypedData_v1', - params: [], + params: undefined, calledNext: false, }, { accountType: BtcAccountType.P2wpkh, method: 'eth_signTypedData_v3', - params: [], + params: undefined, calledNext: false, }, { accountType: BtcAccountType.P2wpkh, method: 'eth_signTypedData_v4', - params: [], + params: undefined, calledNext: false, }, { accountType: EthAccountType.Eoa, method: 'eth_accounts', - params: [], + params: undefined, calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'eth_sendRawTransaction', - params: [], + params: undefined, calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'eth_sendTransaction', - params: [], + params: undefined, calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'eth_signTypedData', - params: [], + params: undefined, calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'eth_signTypedData_v1', - params: [], + params: undefined, calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'eth_signTypedData_v3', - params: [], + params: undefined, calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'eth_signTypedData_v4', - params: [], + params: undefined, calledNext: true, }, @@ -105,25 +106,25 @@ describe('createEvmMethodsToNonEvmAccountReqFilterMiddleware', () => { { accountType: BtcAccountType.P2wpkh, method: 'eth_blockNumber', - params: [], + params: undefined, calledNext: true, }, { accountType: BtcAccountType.P2wpkh, method: 'eth_chainId', - params: [], + params: undefined, calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'eth_blockNumber', - params: [], + params: undefined, calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'eth_chainId', - params: [], + params: undefined, calledNext: true, }, @@ -131,109 +132,109 @@ describe('createEvmMethodsToNonEvmAccountReqFilterMiddleware', () => { { accountType: BtcAccountType.P2wpkh, method: 'wallet_getSnaps', - params: [], + params: undefined, calledNext: true, }, { accountType: BtcAccountType.P2wpkh, method: 'wallet_invokeSnap', - params: [], + params: undefined, calledNext: true, }, { accountType: BtcAccountType.P2wpkh, method: 'wallet_requestSnaps', - params: [], + params: undefined, calledNext: true, }, { accountType: BtcAccountType.P2wpkh, method: 'snap_getClientStatus', - params: [], + params: undefined, calledNext: true, }, { accountType: BtcAccountType.P2wpkh, method: 'wallet_addEthereumChain', - params: [], + params: undefined, calledNext: true, }, { accountType: BtcAccountType.P2wpkh, method: 'wallet_getPermissions', - params: [], + params: undefined, calledNext: true, }, { accountType: BtcAccountType.P2wpkh, method: 'wallet_requestPermissions', - params: [], + params: undefined, calledNext: true, }, { accountType: BtcAccountType.P2wpkh, method: 'wallet_revokePermissions', - params: [], + params: undefined, calledNext: true, }, { accountType: BtcAccountType.P2wpkh, method: 'wallet_switchEthereumChain', - params: [], + params: undefined, calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'wallet_getSnaps', - params: [], + params: undefined, calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'wallet_invokeSnap', - params: [], + params: undefined, calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'wallet_requestSnaps', - params: [], + params: undefined, calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'snap_getClientStatus', - params: [], + params: undefined, calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'wallet_addEthereumChain', - params: [], + params: undefined, calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'wallet_getPermissions', - params: [], + params: undefined, calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'wallet_requestPermissions', - params: [], + params: undefined, calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'wallet_revokePermissions', - params: [], + params: undefined, calledNext: true, }, { accountType: EthAccountType.Eoa, method: 'wallet_switchEthereumChain', - params: [], + params: undefined, calledNext: true, }, @@ -297,7 +298,7 @@ describe('createEvmMethodsToNonEvmAccountReqFilterMiddleware', () => { const mockEnd = jest.fn(); filterFn( - getMockRequest(method, params), + getMockRequest(method, params) as JsonRpcRequest, getMockResponse(), mockNext, mockEnd,