diff --git a/app/scripts/lib/createRPCMethodTrackingMiddleware.js b/app/scripts/lib/createRPCMethodTrackingMiddleware.js index a1c5a036f13f..cb57c681649f 100644 --- a/app/scripts/lib/createRPCMethodTrackingMiddleware.js +++ b/app/scripts/lib/createRPCMethodTrackingMiddleware.js @@ -53,6 +53,8 @@ const RATE_LIMIT_MAP = { [MESSAGE_TYPE.ETH_DECRYPT]: RATE_LIMIT_TYPES.NON_RATE_LIMITED, [MESSAGE_TYPE.ETH_GET_ENCRYPTION_PUBLIC_KEY]: RATE_LIMIT_TYPES.NON_RATE_LIMITED, + [MESSAGE_TYPE.ADD_ETHEREUM_CHAIN]: RATE_LIMIT_TYPES.NON_RATE_LIMITED, + [MESSAGE_TYPE.SWITCH_ETHEREUM_CHAIN]: RATE_LIMIT_TYPES.NON_RATE_LIMITED, [MESSAGE_TYPE.ETH_REQUEST_ACCOUNTS]: RATE_LIMIT_TYPES.TIMEOUT, [MESSAGE_TYPE.WALLET_REQUEST_PERMISSIONS]: RATE_LIMIT_TYPES.TIMEOUT, [MESSAGE_TYPE.SEND_METADATA]: RATE_LIMIT_TYPES.BLOCKED, @@ -126,6 +128,8 @@ const EVENT_NAME_MAP = { */ const TRANSFORM_PARAMS_MAP = { [MESSAGE_TYPE.WATCH_ASSET]: ({ type }) => ({ type }), + [MESSAGE_TYPE.ADD_ETHEREUM_CHAIN]: ([{ chainId }]) => ({ chainId }), + [MESSAGE_TYPE.SWITCH_ETHEREUM_CHAIN]: ([{ chainId }]) => ({ chainId }), }; const rateLimitTimeoutsByMethod = {}; diff --git a/app/scripts/lib/createRPCMethodTrackingMiddleware.test.js b/app/scripts/lib/createRPCMethodTrackingMiddleware.test.js index 01daaf2974a4..244a995bf5f7 100644 --- a/app/scripts/lib/createRPCMethodTrackingMiddleware.test.js +++ b/app/scripts/lib/createRPCMethodTrackingMiddleware.test.js @@ -883,6 +883,34 @@ describe('createRPCMethodTrackingMiddleware', () => { }, { type: 'ERC20' }, ], + [ + 'only the chain ID', + 'wallet_addEthereumChain', + [ + { + chainId: '0x64', + chainName: 'Gnosis', + rpcUrls: ['https://rpc.gnosischain.com'], + iconUrls: [ + 'https://xdaichain.com/fake/example/url/xdai.svg', + 'https://xdaichain.com/fake/example/url/xdai.png', + ], + nativeCurrency: { + name: 'XDAI', + symbol: 'XDAI', + decimals: 18, + }, + blockExplorerUrls: ['https://blockscout.com/poa/xdai/'], + }, + ], + { chainId: '0x64' }, + ], + [ + 'only the chain ID', + 'wallet_switchEthereumChain', + [{ chainId: '0x123' }], + { chainId: '0x123' }, + ], ])( `should include %s in the '%s' tracked events params property`, async (_, method, params, expected) => {