Skip to content

Commit

Permalink
chore(test): json rpc request params can still be undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
legobeat committed Oct 17, 2024
1 parent 40a0197 commit fd14948
Showing 1 changed file with 38 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -19,221 +20,221 @@ 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,
},

// EVM requests not associated with an account
{
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,
},

// other requests
{
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,
},

Expand Down Expand Up @@ -297,7 +298,7 @@ describe('createEvmMethodsToNonEvmAccountReqFilterMiddleware', () => {
const mockEnd = jest.fn();

filterFn(
getMockRequest(method, params),
getMockRequest(method, params) as JsonRpcRequest<JsonRpcParams>,
getMockResponse(),
mockNext,
mockEnd,
Expand Down

0 comments on commit fd14948

Please sign in to comment.