Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devDeps: bump @metamask/eslint-config* to ^12.0.0 #223

Merged
merged 4 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
24 changes: 23 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ module.exports = {
{
files: ['*.ts'],
extends: ['@metamask/eslint-config-typescript'],
rules: {
// TODO: resolve warnings and remove to make into errors
'@typescript-eslint/consistent-type-definitions': 'off',
'@typescript-eslint/naming-convention': 'off',
'@typescript-eslint/prefer-optional-chain': 'warn',
'@typescript-eslint/restrict-template-expressions': 'off',
'id-denylist': 'off',
'id-length': 'off',
'import/no-nodejs-modules': 'off',
'jsdoc/require-jsdoc': 'off',
'jsdoc/require-param-description': 'warn',
'jsdoc/require-hyphen-before-param-description': 'warn',
'jsdoc/match-description': 'warn',
'jsdoc/no-types': 'warn',
'no-restricted-globals': 'off',
'no-restricted-syntax': 'warn',
},
},

{
Expand All @@ -18,9 +35,11 @@ module.exports = {
},

{
files: ['*.test.ts', '*.test.js'],
files: ['*.test.ts', '*.test.js', 'test/**/*.ts'],
extends: ['@metamask/eslint-config-jest'],
rules: {
'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/unbound-method': 'off',
'jest/expect-expect': [
'error',
{
Expand All @@ -30,6 +49,9 @@ module.exports = {
],
},
],
'jsdoc/check-param-names': 'off',
'jsdoc/require-jsdoc': 'off',
'jsdoc/require-param': 'off',
},
},
],
Expand Down
24 changes: 13 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,25 @@
"@jest/globals": "^27.5.1",
"@lavamoat/allow-scripts": "^2.3.1",
"@metamask/auto-changelog": "^3.1.0",
"@metamask/eslint-config": "^8.0.0",
"@metamask/eslint-config-jest": "^8.0.0",
"@metamask/eslint-config-nodejs": "^8.0.0",
"@metamask/eslint-config-typescript": "^8.0.0",
"@metamask/eslint-config": "^12.1.0",
"@metamask/eslint-config-jest": "^12.1.0",
"@metamask/eslint-config-nodejs": "^12.1.0",
"@metamask/eslint-config-typescript": "^12.1.0",
"@types/btoa": "^1.2.3",
"@types/clone": "^2.1.0",
"@types/jest": "^27.4.1",
"@types/node": "^17.0.23",
"@types/pify": "^3.0.2",
"@typescript-eslint/eslint-plugin": "^4.21.0",
"@typescript-eslint/parser": "^4.21.0",
"eslint": "^7.14.0",
"@typescript-eslint/eslint-plugin": "^5.42.1",
"@typescript-eslint/parser": "^5.42.1",
"eslint": "^8.44.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.1.3",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.1.5",
"eslint-plugin-jsdoc": "^39.6.2",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-promise": "^6.1.1",
"jest": "^27.5.1",
"prettier": "^2.2.1",
"prettier-plugin-packagejson": "^2.2.11",
Expand Down
9 changes: 5 additions & 4 deletions src/block-cache.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { providerFromEngine } from '@metamask/eth-json-rpc-provider';
import { PollingBlockTracker } from 'eth-block-tracker';
import { JsonRpcEngine } from 'json-rpc-engine';
import pify from 'pify';
import { providerFromEngine } from '@metamask/eth-json-rpc-provider';
import createHitTrackerMiddleware from '../test/util/createHitTrackerMiddleware';

import { createBlockCacheMiddleware } from '.';
import createHitTrackerMiddleware from '../test/util/createHitTrackerMiddleware';

function createTestSetup() {
// raw data source
Expand Down Expand Up @@ -53,8 +54,8 @@ describe('block cache', () => {
});
expect(hitCountMiddleware.getHits('eth_getBalance')).toHaveLength(2);
expect(hitCount).toBe(1);
expect(response.result).toStrictEqual('0x0');
expect(response2.result).toStrictEqual('0x0');
expect(response.result).toBe('0x0');
expect(response2.result).toBe('0x0');
expect(spy).toHaveBeenCalled();
});
});
23 changes: 13 additions & 10 deletions src/block-cache.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import { PollingBlockTracker } from 'eth-block-tracker';
import { createAsyncMiddleware, JsonRpcRequest } from 'json-rpc-engine';
import type { PollingBlockTracker } from 'eth-block-tracker';
import type { JsonRpcRequest } from 'json-rpc-engine';
import { createAsyncMiddleware } from 'json-rpc-engine';

import { projectLogger, createModuleLogger } from './logging-utils';
import {
cacheIdentifierForRequest,
blockTagForRequest,
cacheTypeForMethod,
canCache,
CacheStrategy,
} from './utils/cache';
import type {
Block,
BlockCache,
// eslint-disable-next-line @typescript-eslint/no-shadow
Cache,
JsonRpcCacheMiddleware,
JsonRpcRequestToCache,
} from './types';
import {
cacheIdentifierForRequest,
blockTagForRequest,
cacheTypeForMethod,
canCache,
CacheStrategy,
} from './utils/cache';

const log = createModuleLogger(projectLogger, 'block-cache');
// `<nil>` comes from https://github.com/ethereum/go-ethereum/issues/16925
Expand All @@ -29,7 +32,7 @@
//

class BlockCacheStrategy {
private cache: Cache;

Check warning on line 35 in src/block-cache.ts

View workflow job for this annotation

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

Use a hash name instead

Check warning on line 35 in src/block-cache.ts

View workflow job for this annotation

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

Use a hash name instead

Check warning on line 35 in src/block-cache.ts

View workflow job for this annotation

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

Use a hash name instead

Check warning on line 35 in src/block-cache.ts

View workflow job for this annotation

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

Use a hash name instead

Check warning on line 35 in src/block-cache.ts

View workflow job for this annotation

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

Use a hash name instead

Check warning on line 35 in src/block-cache.ts

View workflow job for this annotation

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

Use a hash name instead

Check warning on line 35 in src/block-cache.ts

View workflow job for this annotation

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

Use a hash name instead

Check warning on line 35 in src/block-cache.ts

View workflow job for this annotation

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

Use a hash name instead

constructor() {
this.cache = {};
Expand Down Expand Up @@ -107,7 +110,7 @@
)
) {
if (
!result ||

Check warning on line 113 in src/block-cache.ts

View workflow job for this annotation

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

Prefer using an optional chain expression instead, as it's more concise and easier to read

Check warning on line 113 in src/block-cache.ts

View workflow job for this annotation

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

Prefer using an optional chain expression instead, as it's more concise and easier to read

Check warning on line 113 in src/block-cache.ts

View workflow job for this annotation

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

Prefer using an optional chain expression instead, as it's more concise and easier to read

Check warning on line 113 in src/block-cache.ts

View workflow job for this annotation

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

Prefer using an optional chain expression instead, as it's more concise and easier to read

Check warning on line 113 in src/block-cache.ts

View workflow job for this annotation

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

Prefer using an optional chain expression instead, as it's more concise and easier to read

Check warning on line 113 in src/block-cache.ts

View workflow job for this annotation

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

Prefer using an optional chain expression instead, as it's more concise and easier to read

Check warning on line 113 in src/block-cache.ts

View workflow job for this annotation

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

Prefer using an optional chain expression instead, as it's more concise and easier to read

Check warning on line 113 in src/block-cache.ts

View workflow job for this annotation

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

Prefer using an optional chain expression instead, as it's more concise and easier to read
!result.blockHash ||
result.blockHash ===
'0x0000000000000000000000000000000000000000000000000000000000000000'
Expand Down Expand Up @@ -209,7 +212,7 @@
'No cache stored under block number %o, carrying request forward',
requestedBlockNumber,
);
// eslint-disable-next-line node/callback-return
// eslint-disable-next-line n/callback-return
await next();

// add result to cache
Expand Down
6 changes: 4 additions & 2 deletions src/block-ref-rewrite.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { PollingBlockTracker } from 'eth-block-tracker';
import { createAsyncMiddleware, JsonRpcMiddleware } from 'json-rpc-engine';
import type { PollingBlockTracker } from 'eth-block-tracker';
import type { JsonRpcMiddleware } from 'json-rpc-engine';
import { createAsyncMiddleware } from 'json-rpc-engine';

import { blockTagParamIndex } from './utils/cache';

interface BlockRefRewriteMiddlewareOptions {
Expand Down
8 changes: 5 additions & 3 deletions src/block-ref.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { PollingBlockTracker } from 'eth-block-tracker';
import { JsonRpcEngine, JsonRpcMiddleware } from 'json-rpc-engine';
import { providerFromEngine } from '@metamask/eth-json-rpc-provider';
import type { SafeEventEmitterProvider } from '@metamask/eth-json-rpc-provider';
import { PollingBlockTracker } from 'eth-block-tracker';
import type { JsonRpcMiddleware } from 'json-rpc-engine';
import { JsonRpcEngine } from 'json-rpc-engine';

import { createBlockRefMiddleware } from '.';
import {
buildMockParamsWithBlockParamAt,
stubProviderRequests,
Expand All @@ -11,7 +14,6 @@ import {
buildMockParamsWithoutBlockParamAt,
expectProviderRequestNotToHaveBeenMade,
} from '../test/util/helpers';
import { createBlockRefMiddleware } from '.';

/**
* Objects used in each test.
Expand Down
15 changes: 8 additions & 7 deletions src/block-ref.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { PollingBlockTracker } from 'eth-block-tracker';
import {
createAsyncMiddleware,
import type { SafeEventEmitterProvider } from '@metamask/eth-json-rpc-provider';
import clone from 'clone';
import type { PollingBlockTracker } from 'eth-block-tracker';
import type {
JsonRpcMiddleware,
PendingJsonRpcResponse,
} from 'json-rpc-engine';
import clone from 'clone';
import { createAsyncMiddleware } from 'json-rpc-engine';
import pify from 'pify';
import type { SafeEventEmitterProvider } from '@metamask/eth-json-rpc-provider';

import { projectLogger, createModuleLogger } from './logging-utils';
import { blockTagParamIndex } from './utils/cache';
import type { Block } from './types';
import { blockTagParamIndex } from './utils/cache';

interface BlockRefMiddlewareOptions {
blockTracker?: PollingBlockTracker;
Expand Down Expand Up @@ -66,7 +67,7 @@ export function createBlockRefMiddleware({
// perform child request
log('Performing another request %o', childRequest);
const childRes: PendingJsonRpcResponse<Block> = await pify(
(provider as SafeEventEmitterProvider).sendAsync,
provider.sendAsync,
).call(provider, childRequest);
// copy child response onto original response
res.result = childRes.result;
Expand Down
11 changes: 6 additions & 5 deletions src/block-tracker-inspector.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { PollingBlockTracker } from 'eth-block-tracker';
import {
createAsyncMiddleware,
import type { PollingBlockTracker } from 'eth-block-tracker';
import type {
JsonRpcMiddleware,
PendingJsonRpcResponse,
} from 'json-rpc-engine';
import { createAsyncMiddleware } from 'json-rpc-engine';

import { projectLogger, createModuleLogger } from './logging-utils';

const log = createModuleLogger(projectLogger, 'block-tracker-inspector');
Expand All @@ -26,7 +27,7 @@ type ValidPropertyType = string | number | symbol;
*
* @param objectToCheck - The object to check.
* @param property - The property to look for.
* @returns - Whether the object has the property.
* @returns Whether the object has the property.
*/
function hasProperty<ObjectToCheck, Property extends ValidPropertyType>(
objectToCheck: ObjectToCheck,
Expand Down Expand Up @@ -64,7 +65,7 @@ export function createBlockTrackerInspectorMiddleware({
if (!futureBlockRefRequests.includes(req.method)) {
return next();
}
// eslint-disable-next-line node/callback-return
// eslint-disable-next-line n/callback-return
await next();
// abort if no result or no block number
const responseBlockNumber = getResultBlockNumber(res);
Expand Down
14 changes: 7 additions & 7 deletions src/fetch.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import {
createAsyncMiddleware,
JsonRpcMiddleware,
JsonRpcRequest,
} from 'json-rpc-engine';
import { EthereumRpcError, ethErrors } from 'eth-rpc-errors';
import { timeout } from './utils/timeout';
import type { EthereumRpcError } from 'eth-rpc-errors';
import { ethErrors } from 'eth-rpc-errors';
import type { JsonRpcMiddleware, JsonRpcRequest } from 'json-rpc-engine';
import { createAsyncMiddleware } from 'json-rpc-engine';

import type { Block } from './types';
import { timeout } from './utils/timeout';

const RETRIABLE_ERRORS: string[] = [
// ignore server overload errors
Expand Down Expand Up @@ -34,7 +33,7 @@
/**
* Create middleware for sending a JSON-RPC request to the given RPC URL.
*
* @param options - Options

Check warning on line 36 in src/fetch.ts

View workflow job for this annotation

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

JSDoc description does not satisfy the regex pattern

Check warning on line 36 in src/fetch.ts

View workflow job for this annotation

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

JSDoc description does not satisfy the regex pattern

Check warning on line 36 in src/fetch.ts

View workflow job for this annotation

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

JSDoc description does not satisfy the regex pattern

Check warning on line 36 in src/fetch.ts

View workflow job for this annotation

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

JSDoc description does not satisfy the regex pattern

Check warning on line 36 in src/fetch.ts

View workflow job for this annotation

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

JSDoc description does not satisfy the regex pattern

Check warning on line 36 in src/fetch.ts

View workflow job for this annotation

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

JSDoc description does not satisfy the regex pattern

Check warning on line 36 in src/fetch.ts

View workflow job for this annotation

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

JSDoc description does not satisfy the regex pattern

Check warning on line 36 in src/fetch.ts

View workflow job for this annotation

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

JSDoc description does not satisfy the regex pattern
* @param options.btoa - Generates a base64-encoded string from a binary string.
* @param options.fetch - The `fetch` function; expected to be equivalent to `window.fetch`.
* @param options.rpcUrl - The URL to send the request to.
Expand Down Expand Up @@ -141,11 +140,12 @@
/**
* Generate `fetch` configuration for sending the given request to an RPC API.
*
* @param options - Options

Check warning on line 143 in src/fetch.ts

View workflow job for this annotation

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

JSDoc description does not satisfy the regex pattern

Check warning on line 143 in src/fetch.ts

View workflow job for this annotation

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

JSDoc description does not satisfy the regex pattern

Check warning on line 143 in src/fetch.ts

View workflow job for this annotation

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

JSDoc description does not satisfy the regex pattern

Check warning on line 143 in src/fetch.ts

View workflow job for this annotation

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

JSDoc description does not satisfy the regex pattern

Check warning on line 143 in src/fetch.ts

View workflow job for this annotation

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

JSDoc description does not satisfy the regex pattern

Check warning on line 143 in src/fetch.ts

View workflow job for this annotation

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

JSDoc description does not satisfy the regex pattern

Check warning on line 143 in src/fetch.ts

View workflow job for this annotation

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

JSDoc description does not satisfy the regex pattern

Check warning on line 143 in src/fetch.ts

View workflow job for this annotation

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

JSDoc description does not satisfy the regex pattern
* @param options.btoa - Generates a base64-encoded string from a binary string.
* @param options.rpcUrl - The URL to send the request to.
* @param options.originHttpHeaderKey - If provider, the origin field for each JSON-RPC request
* will be attached to each outgoing fetch request under this header.
* @param options.req

Check warning on line 148 in src/fetch.ts

View workflow job for this annotation

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

Missing JSDoc @param "options.req" description

Check warning on line 148 in src/fetch.ts

View workflow job for this annotation

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

Missing JSDoc @param "options.req" description

Check warning on line 148 in src/fetch.ts

View workflow job for this annotation

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

Missing JSDoc @param "options.req" description

Check warning on line 148 in src/fetch.ts

View workflow job for this annotation

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

Missing JSDoc @param "options.req" description

Check warning on line 148 in src/fetch.ts

View workflow job for this annotation

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

Missing JSDoc @param "options.req" description

Check warning on line 148 in src/fetch.ts

View workflow job for this annotation

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

Missing JSDoc @param "options.req" description

Check warning on line 148 in src/fetch.ts

View workflow job for this annotation

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

Missing JSDoc @param "options.req" description

Check warning on line 148 in src/fetch.ts

View workflow job for this annotation

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

Missing JSDoc @param "options.req" description
legobeat marked this conversation as resolved.
Show resolved Hide resolved
* @returns The fetch middleware.
*/
export function createFetchConfigFromReq({
Expand Down
1 change: 1 addition & 0 deletions src/inflight-cache.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { JsonRpcEngine } from 'json-rpc-engine';
import pify from 'pify';

import { createInflightCacheMiddleware } from '.';

function createTestSetup() {
Expand Down
10 changes: 6 additions & 4 deletions src/inflight-cache.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import clone from 'clone';
import { createAsyncMiddleware, PendingJsonRpcResponse } from 'json-rpc-engine';
import type { PendingJsonRpcResponse } from 'json-rpc-engine';
import { createAsyncMiddleware } from 'json-rpc-engine';

import { projectLogger, createModuleLogger } from './logging-utils';
import { cacheIdentifierForRequest } from './utils/cache';
import type { JsonRpcRequestToCache, JsonRpcCacheMiddleware } from './types';
import { cacheIdentifierForRequest } from './utils/cache';

type RequestHandlers = (handledRes: PendingJsonRpcResponse<unknown>) => void;
interface InflightRequest {
Expand Down Expand Up @@ -49,7 +51,7 @@ export function createInflightCacheMiddleware(): JsonRpcCacheMiddleware<
inflightRequests[cacheId] = activeRequestHandlers;
// allow request to be handled normally
log('Carrying original request forward %o', req);
// eslint-disable-next-line node/callback-return
// eslint-disable-next-line n/callback-return
await next();
// clear inflight requests
delete inflightRequests[cacheId];
Expand All @@ -65,7 +67,7 @@ export function createInflightCacheMiddleware(): JsonRpcCacheMiddleware<
},
);

function createActiveRequestHandler(
async function createActiveRequestHandler(
res: PendingJsonRpcResponse<unknown>,
activeRequestHandlers: RequestHandlers[],
): Promise<void> {
Expand Down
5 changes: 4 additions & 1 deletion src/providerAsMiddleware.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { JsonRpcMiddleware, PendingJsonRpcResponse } from 'json-rpc-engine';
import type { SafeEventEmitterProvider } from '@metamask/eth-json-rpc-provider';
import type {
JsonRpcMiddleware,
PendingJsonRpcResponse,
} from 'json-rpc-engine';

export function providerAsMiddleware(
provider: SafeEventEmitterProvider,
Expand Down
14 changes: 6 additions & 8 deletions src/retryOnEmpty.test.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import { PollingBlockTracker } from 'eth-block-tracker';
import {
JsonRpcEngine,
JsonRpcMiddleware,
JsonRpcRequest,
} from 'json-rpc-engine';
import { providerFromEngine } from '@metamask/eth-json-rpc-provider';
import type { SafeEventEmitterProvider } from '@metamask/eth-json-rpc-provider';
import { PollingBlockTracker } from 'eth-block-tracker';
import type { JsonRpcMiddleware, JsonRpcRequest } from 'json-rpc-engine';
import { JsonRpcEngine } from 'json-rpc-engine';

import { createRetryOnEmptyMiddleware } from '.';
import type { ProviderRequestStub } from '../test/util/helpers';
import {
buildFinalMiddlewareWithDefaultResponse,
buildMockParamsWithBlockParamAt,
buildMockParamsWithoutBlockParamAt,
buildSimpleFinalMiddleware,
buildStubForBlockNumberRequest,
expectProviderRequestNotToHaveBeenMade,
ProviderRequestStub,
requestMatches,
stubProviderRequests,
} from '../test/util/helpers';
import { createRetryOnEmptyMiddleware } from '.';

/**
* Objects used in each test.
Expand Down
13 changes: 7 additions & 6 deletions src/retryOnEmpty.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import type { SafeEventEmitterProvider } from '@metamask/eth-json-rpc-provider';
import clone from 'clone';
import { PollingBlockTracker } from 'eth-block-tracker';
import {
createAsyncMiddleware,
import type { PollingBlockTracker } from 'eth-block-tracker';
import type {
JsonRpcMiddleware,
PendingJsonRpcResponse,
} from 'json-rpc-engine';
import type { SafeEventEmitterProvider } from '@metamask/eth-json-rpc-provider';
import { createAsyncMiddleware } from 'json-rpc-engine';
import pify from 'pify';

import { projectLogger, createModuleLogger } from './logging-utils';
import type { Block } from './types';
import { blockTagParamIndex } from './utils/cache';
import { timeout } from './utils/timeout';
import { Block } from './types';

//
// RetryOnEmptyMiddleware will retry any request with an empty response that has
Expand Down Expand Up @@ -103,7 +104,7 @@ export function createRetryOnEmptyMiddleware({
async () => {
log('Performing request %o', childRequest);
const attemptResponse: PendingJsonRpcResponse<Block> = await pify(
(provider as SafeEventEmitterProvider).sendAsync,
provider.sendAsync,
).call(provider, childRequest);
log('Response is %o', attemptResponse);
// verify result
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { JsonRpcMiddleware, JsonRpcRequest } from 'json-rpc-engine';
import type { JsonRpcMiddleware, JsonRpcRequest } from 'json-rpc-engine';

export interface JsonRpcRequestToCache<T> extends JsonRpcRequest<T> {
skipCache?: boolean;
Expand Down
Loading
Loading