Skip to content

Commit badb634

Browse files
authored
Bump @metamask/utils to ^11.7.0 (#404)
This is a prerequisite for upgrading the copy of `AbstractRpcService` in this repo to match the newest version of `@metamask/network-controller`. The only version of `@metamask/utils` that could affect this package is in 11.3.0, where some types were changed so that if they take a type parameter that `extends Json`, they default to `Json` itself. Because of our lint rules, that forced some changes in this PR itself. Regardless, these changes should be backwards-compatible. Additionally, we are using `object` from `@metamask/utils` and that is now deprecated, so we do need to adapt to that at some point. But we can address that in a future PR.
1 parent 4d69af0 commit badb634

10 files changed

+41
-40
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

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

1516
### Removed
1617

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"@metamask/json-rpc-engine": "^10.0.2",
3636
"@metamask/rpc-errors": "^7.0.2",
3737
"@metamask/superstruct": "^3.1.0",
38-
"@metamask/utils": "^11.1.0",
38+
"@metamask/utils": "^11.7.0",
3939
"@types/bn.js": "^5.1.5",
4040
"bn.js": "^5.2.1",
4141
"klona": "^2.0.6",

src/block-tracker-inspector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function hasProperty<ObjectToCheck, Property extends ValidPropertyType>(
3939
}
4040

4141
function getResultBlockNumber(
42-
response: PendingJsonRpcResponse<Json>,
42+
response: PendingJsonRpcResponse,
4343
): string | undefined {
4444
const { result } = response;
4545
if (

src/inflight-cache.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { projectLogger, createModuleLogger } from './logging-utils';
1010
import type { JsonRpcRequestToCache, JsonRpcCacheMiddleware } from './types';
1111
import { cacheIdentifierForRequest } from './utils/cache';
1212

13-
type RequestHandlers = (handledRes: PendingJsonRpcResponse<Json>) => void;
13+
type RequestHandlers = (handledRes: PendingJsonRpcResponse) => void;
1414
interface InflightRequest {
1515
[cacheId: string]: RequestHandlers[];
1616
}
@@ -72,11 +72,11 @@ export function createInflightCacheMiddleware(): JsonRpcCacheMiddleware<
7272
);
7373

7474
async function createActiveRequestHandler(
75-
res: PendingJsonRpcResponse<Json>,
75+
res: PendingJsonRpcResponse,
7676
activeRequestHandlers: RequestHandlers[],
7777
): Promise<void> {
7878
const { resolve, promise } = deferredPromise();
79-
activeRequestHandlers.push((handledRes: PendingJsonRpcResponse<Json>) => {
79+
activeRequestHandlers.push((handledRes: PendingJsonRpcResponse) => {
8080
// append a copy of the result and error to the response
8181
res.result = klona(handledRes.result);
8282
res.error = klona(handledRes.error);
@@ -86,7 +86,7 @@ export function createInflightCacheMiddleware(): JsonRpcCacheMiddleware<
8686
}
8787

8888
function handleActiveRequest(
89-
res: PendingJsonRpcResponse<Json>,
89+
res: PendingJsonRpcResponse,
9090
activeRequestHandlers: RequestHandlers[],
9191
): void {
9292
// use setTimeout so we can resolve our original request first

src/methods/wallet-request-execution-permissions.test.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import type {
2-
Json,
3-
JsonRpcRequest,
4-
PendingJsonRpcResponse,
5-
} from '@metamask/utils';
1+
import type { JsonRpcRequest, PendingJsonRpcResponse } from '@metamask/utils';
62
import { klona } from 'klona';
73

84
import type {
@@ -70,7 +66,7 @@ const RESULT_MOCK: RequestExecutionPermissionsResult = [
7066
describe('wallet_requestExecutionPermissions', () => {
7167
let request: JsonRpcRequest;
7268
let params: RequestExecutionPermissionsRequestParams;
73-
let response: PendingJsonRpcResponse<Json>;
69+
let response: PendingJsonRpcResponse;
7470
let processRequestExecutionPermissionsMock: jest.MockedFunction<ProcessRequestExecutionPermissionsHook>;
7571

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

8682
request = klona(REQUEST_MOCK);
8783
params = request.params as RequestExecutionPermissionsRequestParams;
88-
response = {} as PendingJsonRpcResponse<Json>;
84+
response = {} as PendingJsonRpcResponse;
8985

9086
processRequestExecutionPermissionsMock = jest.fn();
9187
processRequestExecutionPermissionsMock.mockResolvedValue(RESULT_MOCK);

src/methods/wallet-request-execution-permissions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export type ProcessRequestExecutionPermissionsHook = (
6868

6969
export async function walletRequestExecutionPermissions(
7070
req: JsonRpcRequest,
71-
res: PendingJsonRpcResponse<Json>,
71+
res: PendingJsonRpcResponse,
7272
{
7373
processRequestExecutionPermissions,
7474
}: {

src/methods/wallet-revoke-execution-permission.test.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import type {
2-
Json,
3-
JsonRpcRequest,
4-
PendingJsonRpcResponse,
5-
} from '@metamask/utils';
1+
import type { JsonRpcRequest, PendingJsonRpcResponse } from '@metamask/utils';
62
import { klona } from 'klona';
73

84
import type {
@@ -22,7 +18,7 @@ const REQUEST_MOCK = {
2218
describe('wallet_revokeExecutionPermission', () => {
2319
let request: JsonRpcRequest<RevokeExecutionPermissionRequestParams>;
2420
let params: RevokeExecutionPermissionRequestParams;
25-
let response: PendingJsonRpcResponse<Json>;
21+
let response: PendingJsonRpcResponse;
2622
let processRevokeExecutionPermissionMock: jest.MockedFunction<ProcessRevokeExecutionPermissionHook>;
2723

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

3733
request = klona(REQUEST_MOCK);
3834
params = request.params as RevokeExecutionPermissionRequestParams;
39-
response = {} as PendingJsonRpcResponse<Json>;
35+
response = {} as PendingJsonRpcResponse;
4036

4137
processRevokeExecutionPermissionMock = jest.fn();
4238
processRevokeExecutionPermissionMock.mockResolvedValue({});

src/methods/wallet-revoke-execution-permission.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { rpcErrors } from '@metamask/rpc-errors';
22
import type { Infer } from '@metamask/superstruct';
33
import {
4-
type Json,
54
type JsonRpcRequest,
65
object,
76
type PendingJsonRpcResponse,
@@ -31,7 +30,7 @@ export type ProcessRevokeExecutionPermissionHook = (
3130

3231
export async function walletRevokeExecutionPermission(
3332
req: JsonRpcRequest,
34-
res: PendingJsonRpcResponse<Json>,
33+
res: PendingJsonRpcResponse,
3534
{
3635
processRevokeExecutionPermission,
3736
}: {

src/wallet.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,14 @@ WalletMiddlewareOptions): JsonRpcMiddleware<any, Block> {
156156

157157
async function lookupAccounts(
158158
req: JsonRpcRequest,
159-
res: PendingJsonRpcResponse<Json>,
159+
res: PendingJsonRpcResponse,
160160
): Promise<void> {
161161
res.result = await getAccounts(req);
162162
}
163163

164164
async function lookupDefaultAccount(
165165
req: JsonRpcRequest,
166-
res: PendingJsonRpcResponse<Json>,
166+
res: PendingJsonRpcResponse,
167167
): Promise<void> {
168168
const accounts = await getAccounts(req);
169169
res.result = accounts[0] || null;
@@ -175,7 +175,7 @@ WalletMiddlewareOptions): JsonRpcMiddleware<any, Block> {
175175

176176
async function sendTransaction(
177177
req: JsonRpcRequest,
178-
res: PendingJsonRpcResponse<Json>,
178+
res: PendingJsonRpcResponse,
179179
): Promise<void> {
180180
if (!processTransaction) {
181181
throw rpcErrors.methodNotSupported();
@@ -198,7 +198,7 @@ WalletMiddlewareOptions): JsonRpcMiddleware<any, Block> {
198198

199199
async function signTransaction(
200200
req: JsonRpcRequest,
201-
res: PendingJsonRpcResponse<Json>,
201+
res: PendingJsonRpcResponse,
202202
): Promise<void> {
203203
if (!processSignTransaction) {
204204
throw rpcErrors.methodNotSupported();
@@ -224,7 +224,7 @@ WalletMiddlewareOptions): JsonRpcMiddleware<any, Block> {
224224
//
225225
async function signTypedData(
226226
req: JsonRpcRequest,
227-
res: PendingJsonRpcResponse<Json>,
227+
res: PendingJsonRpcResponse,
228228
): Promise<void> {
229229
if (!processTypedMessage) {
230230
throw rpcErrors.methodNotSupported();
@@ -259,7 +259,7 @@ WalletMiddlewareOptions): JsonRpcMiddleware<any, Block> {
259259

260260
async function signTypedDataV3(
261261
req: JsonRpcRequest,
262-
res: PendingJsonRpcResponse<Json>,
262+
res: PendingJsonRpcResponse,
263263
): Promise<void> {
264264
if (!processTypedMessageV3) {
265265
throw rpcErrors.methodNotSupported();
@@ -291,7 +291,7 @@ WalletMiddlewareOptions): JsonRpcMiddleware<any, Block> {
291291

292292
async function signTypedDataV4(
293293
req: JsonRpcRequest,
294-
res: PendingJsonRpcResponse<Json>,
294+
res: PendingJsonRpcResponse,
295295
): Promise<void> {
296296
if (!processTypedMessageV4) {
297297
throw rpcErrors.methodNotSupported();
@@ -323,7 +323,7 @@ WalletMiddlewareOptions): JsonRpcMiddleware<any, Block> {
323323

324324
async function personalSign(
325325
req: JsonRpcRequest,
326-
res: PendingJsonRpcResponse<Json>,
326+
res: PendingJsonRpcResponse,
327327
): Promise<void> {
328328
if (!processPersonalMessage) {
329329
throw rpcErrors.methodNotSupported();
@@ -380,7 +380,7 @@ WalletMiddlewareOptions): JsonRpcMiddleware<any, Block> {
380380

381381
async function personalRecover(
382382
req: JsonRpcRequest,
383-
res: PendingJsonRpcResponse<Json>,
383+
res: PendingJsonRpcResponse,
384384
): Promise<void> {
385385
if (
386386
!req?.params ||
@@ -403,7 +403,7 @@ WalletMiddlewareOptions): JsonRpcMiddleware<any, Block> {
403403

404404
async function encryptionPublicKey(
405405
req: JsonRpcRequest,
406-
res: PendingJsonRpcResponse<Json>,
406+
res: PendingJsonRpcResponse,
407407
): Promise<void> {
408408
if (!processEncryptionPublicKey) {
409409
throw rpcErrors.methodNotSupported();
@@ -425,7 +425,7 @@ WalletMiddlewareOptions): JsonRpcMiddleware<any, Block> {
425425

426426
async function decryptMessage(
427427
req: JsonRpcRequest,
428-
res: PendingJsonRpcResponse<Json>,
428+
res: PendingJsonRpcResponse,
429429
): Promise<void> {
430430
if (!processDecryptMessage) {
431431
throw rpcErrors.methodNotSupported();

yarn.lock

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ __metadata:
10441044
"@metamask/network-controller": 22.2.0
10451045
"@metamask/rpc-errors": ^7.0.2
10461046
"@metamask/superstruct": ^3.1.0
1047-
"@metamask/utils": ^11.1.0
1047+
"@metamask/utils": ^11.7.0
10481048
"@types/bn.js": ^5.1.5
10491049
"@types/btoa": ^1.2.3
10501050
"@types/jest": ^27.4.1
@@ -1202,20 +1202,22 @@ __metadata:
12021202
languageName: node
12031203
linkType: hard
12041204

1205-
"@metamask/utils@npm:^11.0.1, @metamask/utils@npm:^11.1.0":
1206-
version: 11.1.0
1207-
resolution: "@metamask/utils@npm:11.1.0"
1205+
"@metamask/utils@npm:^11.0.1, @metamask/utils@npm:^11.1.0, @metamask/utils@npm:^11.7.0":
1206+
version: 11.7.0
1207+
resolution: "@metamask/utils@npm:11.7.0"
12081208
dependencies:
12091209
"@ethereumjs/tx": ^4.2.0
12101210
"@metamask/superstruct": ^3.1.0
12111211
"@noble/hashes": ^1.3.1
12121212
"@scure/base": ^1.1.3
12131213
"@types/debug": ^4.1.7
1214+
"@types/lodash": ^4.17.20
12141215
debug: ^4.3.4
1216+
lodash: ^4.17.21
12151217
pony-cause: ^2.1.10
12161218
semver: ^7.5.4
12171219
uuid: ^9.0.1
1218-
checksum: 41ec84e9198969bb5a0e7a1f5426ca886a62f6d47456a1575f60b2712b9078829d0c3a947bbfffd47ca832447591b36b64a4ce767e56a6fc0304e4a1b9ec5231
1220+
checksum: 8fb694d40f523c11e213c2a997db559bf6472d2181fc89d91167c8a8e3487da9c3f8336de74c7a8f9944222d7f1ddd8b89eea021a83db871dfeb4858bbdd1a47
12191221
languageName: node
12201222
linkType: hard
12211223

@@ -1669,6 +1671,13 @@ __metadata:
16691671
languageName: node
16701672
linkType: hard
16711673

1674+
"@types/lodash@npm:^4.17.20":
1675+
version: 4.17.20
1676+
resolution: "@types/lodash@npm:4.17.20"
1677+
checksum: dc7bb4653514dd91117a4c4cec2c37e2b5a163d7643445e4757d76a360fabe064422ec7a42dde7450c5e7e0e7e678d5e6eae6d2a919abcddf581d81e63e63839
1678+
languageName: node
1679+
linkType: hard
1680+
16721681
"@types/minimatch@npm:*":
16731682
version: 5.1.2
16741683
resolution: "@types/minimatch@npm:5.1.2"
@@ -5378,7 +5387,7 @@ __metadata:
53785387
languageName: node
53795388
linkType: hard
53805389

5381-
"lodash@npm:^4.7.0":
5390+
"lodash@npm:^4.17.21, lodash@npm:^4.7.0":
53825391
version: 4.17.21
53835392
resolution: "lodash@npm:4.17.21"
53845393
checksum: eb835a2e51d381e561e508ce932ea50a8e5a68f4ebdd771ea240d3048244a8d13658acbd502cd4829768c56f2e16bdd4340b9ea141297d472517b83868e677f7

0 commit comments

Comments
 (0)