Bump dev (w/ eslint 8) (#4070)
* Bump dev (w/ eslint 8) * Additional linting * Additional * More lint fixes * Last batch * Additional * Cleanups
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
// Copyright 2017-2021 @polkadot/rpc-provider authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Request } from '../../test/mockWs';
|
||||
|
||||
import { mockWs } from '../../test/mockWs';
|
||||
import { Mock } from './../mock/types';
|
||||
import { WsProvider } from './';
|
||||
@@ -10,7 +12,7 @@ const TEST_WS_URL = 'ws://localhost-index.spec.ts:9977';
|
||||
let provider: WsProvider | null;
|
||||
let mock: Mock;
|
||||
|
||||
function createWs (requests: any[], autoConnect = 1000, headers?: Record<string, string>): WsProvider {
|
||||
function createWs (requests: Request[], autoConnect = 1000, headers?: Record<string, string>): WsProvider {
|
||||
mock = mockWs(requests, TEST_WS_URL);
|
||||
provider = new WsProvider(TEST_WS_URL, autoConnect, headers);
|
||||
|
||||
|
||||
@@ -337,7 +337,7 @@ export class WsProvider implements ProviderInterface {
|
||||
|
||||
#emit = (type: ProviderInterfaceEmitted, ...args: unknown[]): void => {
|
||||
this.#eventemitter.emit(type, ...args);
|
||||
}
|
||||
};
|
||||
|
||||
#onSocketClose = (event: CloseEvent): void => {
|
||||
const error = new Error(`disconnected from ${this.#endpoints[this.#endpointIndex]}: ${event.code}:: ${event.reason || getWSErrorString(event.code)}`);
|
||||
@@ -369,12 +369,12 @@ export class WsProvider implements ProviderInterface {
|
||||
});
|
||||
}, this.#autoConnectMs);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#onSocketError = (error: Event): void => {
|
||||
l.debug(() => ['socket error', error]);
|
||||
this.#emit('error', error);
|
||||
}
|
||||
};
|
||||
|
||||
#onSocketMessage = (message: MessageEvent<string>): void => {
|
||||
l.debug(() => ['received', message.data]);
|
||||
@@ -384,7 +384,7 @@ export class WsProvider implements ProviderInterface {
|
||||
return isUndefined(response.method)
|
||||
? this.#onSocketMessageResult(response)
|
||||
: this.#onSocketMessageSubscribe(response);
|
||||
}
|
||||
};
|
||||
|
||||
#onSocketMessageResult = (response: JsonRpcResponse): void => {
|
||||
const handler = this.#handlers[response.id];
|
||||
@@ -422,7 +422,7 @@ export class WsProvider implements ProviderInterface {
|
||||
}
|
||||
|
||||
delete this.#handlers[response.id];
|
||||
}
|
||||
};
|
||||
|
||||
#onSocketMessageSubscribe = (response: JsonRpcResponse): void => {
|
||||
const method = ALIASES[response.method as string] || response.method || 'invalid';
|
||||
@@ -448,7 +448,7 @@ export class WsProvider implements ProviderInterface {
|
||||
} catch (error) {
|
||||
handler.callback(error as Error, undefined);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#onSocketOpen = (): boolean => {
|
||||
assert(!isNull(this.#websocket), 'WebSocket cannot be null in onOpen');
|
||||
@@ -461,7 +461,7 @@ export class WsProvider implements ProviderInterface {
|
||||
this.#resubscribe();
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
#resubscribe = (): void => {
|
||||
const subscriptions = this.#subscriptions;
|
||||
@@ -484,5 +484,5 @@ export class WsProvider implements ProviderInterface {
|
||||
l.error(error);
|
||||
}
|
||||
})).catch(l.error);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Constructor } from '@polkadot/types/types';
|
||||
import type { Request } from '../../test/mockWs';
|
||||
|
||||
import { mockWs } from '../../test/mockWs';
|
||||
import { Global, Mock } from './../mock/types';
|
||||
@@ -14,7 +15,7 @@ const TEST_WS_URL = 'ws://localhost-send.spec.ts:9965';
|
||||
let provider: WsProvider | null;
|
||||
let mock: Mock;
|
||||
|
||||
function createMock (requests: any[]): void {
|
||||
function createMock (requests: Request[]): void {
|
||||
mock = mockWs(requests, TEST_WS_URL);
|
||||
}
|
||||
|
||||
@@ -89,7 +90,8 @@ describe('send', (): void => {
|
||||
code: 666,
|
||||
message: 'error'
|
||||
},
|
||||
id: 1
|
||||
id: 1,
|
||||
method: 'something'
|
||||
}]);
|
||||
|
||||
return createWs().then((ws) =>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Constructor } from '@polkadot/types/types';
|
||||
import type { Request } from '../../test/mockWs';
|
||||
|
||||
import { mockWs } from '../../test/mockWs';
|
||||
import { Global, Mock } from './../mock/types';
|
||||
@@ -14,7 +15,7 @@ const TEST_WS_URL = 'ws://localhost-subscribe.test.ts:9933';
|
||||
let provider: WsProvider | null;
|
||||
let mock: Mock;
|
||||
|
||||
function createMock (requests: any[]): void {
|
||||
function createMock (requests: Request[]): void {
|
||||
mock = mockWs(requests, TEST_WS_URL);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { Constructor } from '@polkadot/types/types';
|
||||
import type { Request } from '../../test/mockWs';
|
||||
|
||||
import { mockWs } from '../../test/mockWs';
|
||||
import { Global, Mock } from './../mock/types';
|
||||
@@ -14,7 +15,7 @@ const TEST_WS_URL = 'ws://localhost-unsubscribe.test.ts:9933';
|
||||
let provider: WsProvider | null;
|
||||
let mock: Mock;
|
||||
|
||||
function createMock (requests: any): void {
|
||||
function createMock (requests: Request[]): void {
|
||||
mock = mockWs(requests, TEST_WS_URL);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user