Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- **BREAKING:** `createFetchMiddleware` no longer takes `fetch`, `btoa`, `rpcUrl`, and `originHttpHeaderKey` ([#402](https://github.com/MetaMask/eth-json-rpc-middleware/pull/402))
- The existing signature (`rpcService` and `options`) is now the only way to use this function; please use that instead.
- Bump `@metamask/utils` to `^11.7.0` ([#404](https://github.com/MetaMask/eth-json-rpc-middleware/pull/404))

### Removed

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@metamask/json-rpc-engine": "^10.0.2",
"@metamask/rpc-errors": "^7.0.2",
"@metamask/superstruct": "^3.1.0",
"@metamask/utils": "^11.1.0",
"@metamask/utils": "^11.7.0",
"@types/bn.js": "^5.1.5",
"bn.js": "^5.2.1",
"klona": "^2.0.6",
Expand Down
2 changes: 1 addition & 1 deletion src/block-tracker-inspector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function hasProperty<ObjectToCheck, Property extends ValidPropertyType>(
}

function getResultBlockNumber(
response: PendingJsonRpcResponse<Json>,
response: PendingJsonRpcResponse,
): string | undefined {
const { result } = response;
if (
Expand Down
8 changes: 4 additions & 4 deletions src/inflight-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { projectLogger, createModuleLogger } from './logging-utils';
import type { JsonRpcRequestToCache, JsonRpcCacheMiddleware } from './types';
import { cacheIdentifierForRequest } from './utils/cache';

type RequestHandlers = (handledRes: PendingJsonRpcResponse<Json>) => void;
type RequestHandlers = (handledRes: PendingJsonRpcResponse) => void;
interface InflightRequest {
[cacheId: string]: RequestHandlers[];
}
Expand Down Expand Up @@ -72,11 +72,11 @@ export function createInflightCacheMiddleware(): JsonRpcCacheMiddleware<
);

async function createActiveRequestHandler(
res: PendingJsonRpcResponse<Json>,
res: PendingJsonRpcResponse,
activeRequestHandlers: RequestHandlers[],
): Promise<void> {
const { resolve, promise } = deferredPromise();
activeRequestHandlers.push((handledRes: PendingJsonRpcResponse<Json>) => {
activeRequestHandlers.push((handledRes: PendingJsonRpcResponse) => {
// append a copy of the result and error to the response
res.result = klona(handledRes.result);
res.error = klona(handledRes.error);
Expand All @@ -86,7 +86,7 @@ export function createInflightCacheMiddleware(): JsonRpcCacheMiddleware<
}

function handleActiveRequest(
res: PendingJsonRpcResponse<Json>,
res: PendingJsonRpcResponse,
activeRequestHandlers: RequestHandlers[],
): void {
// use setTimeout so we can resolve our original request first
Expand Down
2 changes: 1 addition & 1 deletion src/methods/wallet-get-calls-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export type GetCallsStatusHook = (

export async function walletGetCallsStatus(
req: JsonRpcRequest,
res: PendingJsonRpcResponse<Json>,
res: PendingJsonRpcResponse,
{
getCallsStatus,
}: {
Expand Down
2 changes: 1 addition & 1 deletion src/methods/wallet-get-capabilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export type GetCapabilitiesHook = (

export async function walletGetCapabilities(
req: JsonRpcRequest,
res: PendingJsonRpcResponse<Json>,
res: PendingJsonRpcResponse,
{
getAccounts,
getCapabilities,
Expand Down
10 changes: 3 additions & 7 deletions src/methods/wallet-request-execution-permissions.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import type {
Json,
JsonRpcRequest,
PendingJsonRpcResponse,
} from '@metamask/utils';
import type { JsonRpcRequest, PendingJsonRpcResponse } from '@metamask/utils';
import { klona } from 'klona';

import type {
Expand Down Expand Up @@ -70,7 +66,7 @@ const RESULT_MOCK: RequestExecutionPermissionsResult = [
describe('wallet_requestExecutionPermissions', () => {
let request: JsonRpcRequest;
let params: RequestExecutionPermissionsRequestParams;
let response: PendingJsonRpcResponse<Json>;
let response: PendingJsonRpcResponse;
let processRequestExecutionPermissionsMock: jest.MockedFunction<ProcessRequestExecutionPermissionsHook>;

async function callMethod() {
Expand All @@ -85,7 +81,7 @@ describe('wallet_requestExecutionPermissions', () => {

request = klona(REQUEST_MOCK);
params = request.params as RequestExecutionPermissionsRequestParams;
response = {} as PendingJsonRpcResponse<Json>;
response = {} as PendingJsonRpcResponse;

processRequestExecutionPermissionsMock = jest.fn();
processRequestExecutionPermissionsMock.mockResolvedValue(RESULT_MOCK);
Expand Down
2 changes: 1 addition & 1 deletion src/methods/wallet-request-execution-permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export type ProcessRequestExecutionPermissionsHook = (

export async function walletRequestExecutionPermissions(
req: JsonRpcRequest,
res: PendingJsonRpcResponse<Json>,
res: PendingJsonRpcResponse,
{
processRequestExecutionPermissions,
}: {
Expand Down
10 changes: 3 additions & 7 deletions src/methods/wallet-revoke-execution-permission.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import type {
Json,
JsonRpcRequest,
PendingJsonRpcResponse,
} from '@metamask/utils';
import type { JsonRpcRequest, PendingJsonRpcResponse } from '@metamask/utils';
import { klona } from 'klona';

import type {
Expand All @@ -22,7 +18,7 @@ const REQUEST_MOCK = {
describe('wallet_revokeExecutionPermission', () => {
let request: JsonRpcRequest<RevokeExecutionPermissionRequestParams>;
let params: RevokeExecutionPermissionRequestParams;
let response: PendingJsonRpcResponse<Json>;
let response: PendingJsonRpcResponse;
let processRevokeExecutionPermissionMock: jest.MockedFunction<ProcessRevokeExecutionPermissionHook>;

async function callMethod() {
Expand All @@ -36,7 +32,7 @@ describe('wallet_revokeExecutionPermission', () => {

request = klona(REQUEST_MOCK);
params = request.params as RevokeExecutionPermissionRequestParams;
response = {} as PendingJsonRpcResponse<Json>;
response = {} as PendingJsonRpcResponse;

processRevokeExecutionPermissionMock = jest.fn();
processRevokeExecutionPermissionMock.mockResolvedValue({});
Expand Down
3 changes: 1 addition & 2 deletions src/methods/wallet-revoke-execution-permission.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { rpcErrors } from '@metamask/rpc-errors';
import type { Infer } from '@metamask/superstruct';
import {
type Json,
type JsonRpcRequest,
object,
type PendingJsonRpcResponse,
Expand Down Expand Up @@ -31,7 +30,7 @@ export type ProcessRevokeExecutionPermissionHook = (

export async function walletRevokeExecutionPermission(
req: JsonRpcRequest,
res: PendingJsonRpcResponse<Json>,
res: PendingJsonRpcResponse,
{
processRevokeExecutionPermission,
}: {
Expand Down
2 changes: 1 addition & 1 deletion src/methods/wallet-send-calls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export type ProcessSendCallsHook = (

export async function walletSendCalls(
req: JsonRpcRequest,
res: PendingJsonRpcResponse<Json>,
res: PendingJsonRpcResponse,
{
getAccounts,
processSendCalls,
Expand Down
22 changes: 11 additions & 11 deletions src/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,14 @@

async function lookupAccounts(
req: JsonRpcRequest,
res: PendingJsonRpcResponse<Json>,
res: PendingJsonRpcResponse,
): Promise<void> {
res.result = await getAccounts(req);
}

async function lookupDefaultAccount(
req: JsonRpcRequest,
res: PendingJsonRpcResponse<Json>,
res: PendingJsonRpcResponse,
): Promise<void> {
const accounts = await getAccounts(req);
res.result = accounts[0] || null;
Expand All @@ -200,7 +200,7 @@

async function sendTransaction(
req: JsonRpcRequest,
res: PendingJsonRpcResponse<Json>,
res: PendingJsonRpcResponse,
): Promise<void> {
if (!processTransaction) {
throw rpcErrors.methodNotSupported();
Expand All @@ -223,7 +223,7 @@

async function signTransaction(
req: JsonRpcRequest,
res: PendingJsonRpcResponse<Json>,
res: PendingJsonRpcResponse,
): Promise<void> {
if (!processSignTransaction) {
throw rpcErrors.methodNotSupported();
Expand All @@ -249,7 +249,7 @@
//
async function signTypedData(
req: JsonRpcRequest,
res: PendingJsonRpcResponse<Json>,
res: PendingJsonRpcResponse,
): Promise<void> {
if (!processTypedMessage) {
throw rpcErrors.methodNotSupported();
Expand Down Expand Up @@ -284,7 +284,7 @@

async function signTypedDataV3(
req: JsonRpcRequest,
res: PendingJsonRpcResponse<Json>,
res: PendingJsonRpcResponse,
): Promise<void> {
if (!processTypedMessageV3) {
throw rpcErrors.methodNotSupported();
Expand Down Expand Up @@ -316,7 +316,7 @@

async function signTypedDataV4(
req: JsonRpcRequest,
res: PendingJsonRpcResponse<Json>,
res: PendingJsonRpcResponse,
): Promise<void> {
if (!processTypedMessageV4) {
throw rpcErrors.methodNotSupported();
Expand Down Expand Up @@ -348,7 +348,7 @@

async function personalSign(
req: JsonRpcRequest,
res: PendingJsonRpcResponse<Json>,
res: PendingJsonRpcResponse,
): Promise<void> {
if (!processPersonalMessage) {
throw rpcErrors.methodNotSupported();
Expand Down Expand Up @@ -405,7 +405,7 @@

async function personalRecover(
req: JsonRpcRequest,
res: PendingJsonRpcResponse<Json>,
res: PendingJsonRpcResponse,
): Promise<void> {
if (
!req?.params ||
Expand All @@ -428,7 +428,7 @@

async function encryptionPublicKey(
req: JsonRpcRequest,
res: PendingJsonRpcResponse<Json>,
res: PendingJsonRpcResponse,
): Promise<void> {
if (!processEncryptionPublicKey) {
throw rpcErrors.methodNotSupported();
Expand All @@ -450,7 +450,7 @@

async function decryptMessage(
req: JsonRpcRequest,
res: PendingJsonRpcResponse<Json>,
res: PendingJsonRpcResponse,
): Promise<void> {
if (!processDecryptMessage) {
throw rpcErrors.methodNotSupported();
Expand Down Expand Up @@ -486,7 +486,7 @@
*
* @param address - The address to validate and normalize.
* @param req - The request object.
* @returns {string} - The normalized address, if valid. Otherwise, throws

Check warning on line 489 in src/wallet.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (22.x)

Types are not permitted on @returns

Check warning on line 489 in src/wallet.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (22.x)

JSDoc description does not satisfy the regex pattern

Check warning on line 489 in src/wallet.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (22.x)

There must be no hyphen before @returns description
* an error
*/
async function validateAndNormalizeKeyholder(
Expand Down Expand Up @@ -521,7 +521,7 @@
/**
* Validates verifyingContract of typedSignMessage.
*
* @param data - The data passed in typedSign request.

Check warning on line 524 in src/wallet.ts

View workflow job for this annotation

GitHub Actions / Build, lint, and test / Lint (22.x)

JSDoc description does not satisfy the regex pattern
* This function allows the verifyingContract to be either:
* - A valid hex address
* - The string "cosmos" (as it is hard-coded in some Cosmos ecosystem's EVM adapters)
Expand Down
21 changes: 15 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ __metadata:
"@metamask/network-controller": 22.2.0
"@metamask/rpc-errors": ^7.0.2
"@metamask/superstruct": ^3.1.0
"@metamask/utils": ^11.1.0
"@metamask/utils": ^11.7.0
"@types/bn.js": ^5.1.5
"@types/btoa": ^1.2.3
"@types/jest": ^27.4.1
Expand Down Expand Up @@ -1202,20 +1202,22 @@ __metadata:
languageName: node
linkType: hard

"@metamask/utils@npm:^11.0.1, @metamask/utils@npm:^11.1.0":
version: 11.1.0
resolution: "@metamask/utils@npm:11.1.0"
"@metamask/utils@npm:^11.0.1, @metamask/utils@npm:^11.1.0, @metamask/utils@npm:^11.7.0":
version: 11.7.0
resolution: "@metamask/utils@npm:11.7.0"
dependencies:
"@ethereumjs/tx": ^4.2.0
"@metamask/superstruct": ^3.1.0
"@noble/hashes": ^1.3.1
"@scure/base": ^1.1.3
"@types/debug": ^4.1.7
"@types/lodash": ^4.17.20
debug: ^4.3.4
lodash: ^4.17.21
pony-cause: ^2.1.10
semver: ^7.5.4
uuid: ^9.0.1
checksum: 41ec84e9198969bb5a0e7a1f5426ca886a62f6d47456a1575f60b2712b9078829d0c3a947bbfffd47ca832447591b36b64a4ce767e56a6fc0304e4a1b9ec5231
checksum: 8fb694d40f523c11e213c2a997db559bf6472d2181fc89d91167c8a8e3487da9c3f8336de74c7a8f9944222d7f1ddd8b89eea021a83db871dfeb4858bbdd1a47
languageName: node
linkType: hard

Expand Down Expand Up @@ -1669,6 +1671,13 @@ __metadata:
languageName: node
linkType: hard

"@types/lodash@npm:^4.17.20":
version: 4.17.20
resolution: "@types/lodash@npm:4.17.20"
checksum: dc7bb4653514dd91117a4c4cec2c37e2b5a163d7643445e4757d76a360fabe064422ec7a42dde7450c5e7e0e7e678d5e6eae6d2a919abcddf581d81e63e63839
languageName: node
linkType: hard

"@types/minimatch@npm:*":
version: 5.1.2
resolution: "@types/minimatch@npm:5.1.2"
Expand Down Expand Up @@ -5378,7 +5387,7 @@ __metadata:
languageName: node
linkType: hard

"lodash@npm:^4.7.0":
"lodash@npm:^4.17.21, lodash@npm:^4.7.0":
version: 4.17.21
resolution: "lodash@npm:4.17.21"
checksum: eb835a2e51d381e561e508ce932ea50a8e5a68f4ebdd771ea240d3048244a8d13658acbd502cd4829768c56f2e16bdd4340b9ea141297d472517b83868e677f7
Expand Down
Loading