Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

web3-rpc-providers

Package Overview
Dependencies
Maintainers
4
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web3-rpc-providers - npm Package Compare versions

Comparing version 1.0.0-dev.d9d0391.0 to 1.0.0-dev.dcd9d6a.0

4

lib/commonjs/errors.d.ts

@@ -6,1 +6,5 @@ import { BaseWeb3Error } from 'web3-errors';

}
export declare class ProviderConfigOptionsError extends BaseWeb3Error {
code: number;
constructor(msg: string);
}

@@ -19,3 +19,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.QuickNodeRateLimitError = void 0;
exports.ProviderConfigOptionsError = exports.QuickNodeRateLimitError = void 0;
/* eslint-disable max-classes-per-file */
const web3_errors_1 = require("web3-errors");

@@ -30,2 +31,11 @@ const ERR_QUICK_NODE_RATE_LIMIT = 1300;

exports.QuickNodeRateLimitError = QuickNodeRateLimitError;
const ERR_PROVIDER_CONFIG_OPTIONS = 1301;
class ProviderConfigOptionsError extends web3_errors_1.BaseWeb3Error {
constructor(msg) {
super(`Invalid provider config options given for ${msg}`);
this.code = ERR_PROVIDER_CONFIG_OPTIONS;
}
}
exports.ProviderConfigOptionsError = ProviderConfigOptionsError;
/* eslint-enable max-classes-per-file */
//# sourceMappingURL=errors.js.map

@@ -0,1 +1,5 @@

/// <reference types="ws" />
/// <reference types="node" />
import { ClientOptions, ClientRequestArgs } from 'web3-providers-ws';
import { ReconnectOptions } from 'web3-utils';
export declare enum Transport {

@@ -22,1 +26,5 @@ HTTPS = "https",

}
export declare type SocketOptions = {
socketOptions?: ClientOptions | ClientRequestArgs;
reconnectOptions?: Partial<ReconnectOptions>;
};

2

lib/commonjs/types.js

@@ -25,3 +25,2 @@ "use strict";

})(Transport = exports.Transport || (exports.Transport = {}));
;
var Network;

@@ -45,3 +44,2 @@ (function (Network) {

})(Network = exports.Network || (exports.Network = {}));
;
//# sourceMappingURL=types.js.map

@@ -1,8 +0,9 @@

import { EthExecutionAPI, JsonRpcResponseWithResult, Web3APIMethod, Web3APIPayload, Web3APIReturnType, Web3APISpec } from "web3-types";
import { Transport, Network } from "./types.js";
import { Web3ExternalProvider } from "./web3_provider.js";
import { EthExecutionAPI, JsonRpcResponseWithResult, Web3APIMethod, Web3APIPayload, Web3APIReturnType, Web3APISpec } from 'web3-types';
import { HttpProviderOptions } from 'web3-providers-http';
import { Transport, Network, SocketOptions } from './types.js';
import { Web3ExternalProvider } from './web3_provider.js';
export declare class QuickNodeProvider<API extends Web3APISpec = EthExecutionAPI> extends Web3ExternalProvider {
constructor(network?: Network, transport?: Transport, token?: string, host?: string);
constructor(network?: Network, transport?: Transport, token?: string, host?: string, providerConfigOptions?: HttpProviderOptions | SocketOptions);
request<Method extends Web3APIMethod<API>, ResultType = Web3APIReturnType<API, Method>>(payload: Web3APIPayload<EthExecutionAPI, Method>, requestOptions?: RequestInit): Promise<JsonRpcResponseWithResult<ResultType>>;
getRPCURL(network: Network, transport: Transport, _token: string, _host: string): string;
}

@@ -35,4 +35,5 @@ "use strict";

class QuickNodeProvider extends web3_provider_js_1.Web3ExternalProvider {
constructor(network = types_js_1.Network.ETH_MAINNET, transport = types_js_1.Transport.HTTPS, token = "", host = "") {
super(network, transport, token, host);
// eslint-disable-next-line default-param-last
constructor(network = types_js_1.Network.ETH_MAINNET, transport = types_js_1.Transport.HTTPS, token = '', host = '', providerConfigOptions) {
super(network, transport, token, host, providerConfigOptions);
}

@@ -57,43 +58,47 @@ request(payload, requestOptions) {

getRPCURL(network, transport, _token, _host) {
let host = "";
let token = "";
let host = '';
let token = '';
switch (network) {
case types_js_1.Network.ETH_MAINNET:
host = isValid(_host) ? _host : "powerful-holy-bush.quiknode.pro";
token = isValid(_token) ? _token : "3240624a343867035925ff7561eb60dfdba2a668";
host = isValid(_host) ? _host : 'powerful-holy-bush.quiknode.pro';
token = isValid(_token) ? _token : '3240624a343867035925ff7561eb60dfdba2a668';
break;
case types_js_1.Network.ETH_SEPOLIA:
host = isValid(_host) ? _host : "dimensional-fabled-glitter.ethereum-sepolia.quiknode.pro";
token = isValid(_token) ? _token : "382a3b5a4b938f2d6e8686c19af4b22921fde2cd";
host = isValid(_host)
? _host
: 'dimensional-fabled-glitter.ethereum-sepolia.quiknode.pro';
token = isValid(_token) ? _token : '382a3b5a4b938f2d6e8686c19af4b22921fde2cd';
break;
case types_js_1.Network.ETH_HOLESKY:
host = isValid(_host) ? _host : "yolo-morning-card.ethereum-holesky.quiknode.pro";
token = isValid(_token) ? _token : "481ebe70638c4dcf176af617a16d02ab866b9af9";
host = isValid(_host) ? _host : 'yolo-morning-card.ethereum-holesky.quiknode.pro';
token = isValid(_token) ? _token : '481ebe70638c4dcf176af617a16d02ab866b9af9';
break;
case types_js_1.Network.ARBITRUM_MAINNET:
host = isValid(_host) ? _host : "autumn-divine-dinghy.arbitrum-mainnet.quiknode.pro";
token = isValid(_token) ? _token : "a5d7bfbf60b5ae9ce3628e53d69ef50d529e9a8c";
host = isValid(_host)
? _host
: 'autumn-divine-dinghy.arbitrum-mainnet.quiknode.pro';
token = isValid(_token) ? _token : 'a5d7bfbf60b5ae9ce3628e53d69ef50d529e9a8c';
break;
case types_js_1.Network.ARBITRUM_SEPOLIA:
host = isValid(_host) ? _host : "few-patient-pond.arbitrum-sepolia.quiknode.pro";
token = isValid(_token) ? _token : "3be985450970628c860b959c65cd2642dcafe53c";
host = isValid(_host) ? _host : 'few-patient-pond.arbitrum-sepolia.quiknode.pro';
token = isValid(_token) ? _token : '3be985450970628c860b959c65cd2642dcafe53c';
break;
case types_js_1.Network.BNB_MAINNET:
host = isValid(_host) ? _host : "purple-empty-reel.bsc.quiknode.pro";
token = isValid(_token) ? _token : "ebf6c532961e21f092ff2facce1ec4c89c540158";
host = isValid(_host) ? _host : 'purple-empty-reel.bsc.quiknode.pro';
token = isValid(_token) ? _token : 'ebf6c532961e21f092ff2facce1ec4c89c540158';
break;
case types_js_1.Network.BNB_TESTNET:
host = isValid(_host) ? _host : "floral-rough-scion.bsc-testnet.quiknode.pro";
token = isValid(_token) ? _token : "5b297e5acff5f81f4c37ebf6f235f7299b6f9d28";
host = isValid(_host) ? _host : 'floral-rough-scion.bsc-testnet.quiknode.pro';
token = isValid(_token) ? _token : '5b297e5acff5f81f4c37ebf6f235f7299b6f9d28';
break;
case types_js_1.Network.POLYGON_MAINNET:
host = isValid(_host) ? _host : "small-chaotic-moon.matic.quiknode.pro";
token = isValid(_token) ? _token : "847569f8a017e84d985e10d0f44365d965a951f1";
host = isValid(_host) ? _host : 'small-chaotic-moon.matic.quiknode.pro';
token = isValid(_token) ? _token : '847569f8a017e84d985e10d0f44365d965a951f1';
break;
case types_js_1.Network.POLYGON_AMONY:
host = isValid(_host) ? _host : "prettiest-side-shape.matic-amoy.quiknode.pro";
token = isValid(_token) ? _token : "79a9476eea661d4f82de614db1d8a895b14b881c";
host = isValid(_host) ? _host : 'prettiest-side-shape.matic-amoy.quiknode.pro';
token = isValid(_token) ? _token : '79a9476eea661d4f82de614db1d8a895b14b881c';
break;
default:
throw new Error("Network info not avalible.");
throw new Error('Network info not avalible.');
}

@@ -100,0 +105,0 @@ return `${transport}://${host}/${token}`;

@@ -1,4 +0,5 @@

import { EthExecutionAPI, JsonRpcResult, ProviderConnectInfo, ProviderMessage, ProviderRpcError, Web3APIMethod, Web3APIPayload, Web3APIReturnType, Web3APISpec, Web3BaseProvider, Web3Eip1193ProviderEventCallback, Web3ProviderEventCallback, Web3ProviderMessageEventCallback, Web3ProviderStatus, JsonRpcResponseWithResult } from "web3-types";
import { Eip1193Provider } from "web3-utils";
import { Transport, Network } from "./types.js";
import { HttpProviderOptions } from 'web3-providers-http';
import { EthExecutionAPI, JsonRpcResult, ProviderConnectInfo, ProviderMessage, ProviderRpcError, Web3APIMethod, Web3APIPayload, Web3APIReturnType, Web3APISpec, Web3BaseProvider, Web3Eip1193ProviderEventCallback, Web3ProviderEventCallback, Web3ProviderMessageEventCallback, Web3ProviderStatus, JsonRpcResponseWithResult } from 'web3-types';
import { Eip1193Provider } from 'web3-utils';
import { Transport, Network, SocketOptions } from './types.js';
export declare abstract class Web3ExternalProvider<API extends Web3APISpec = EthExecutionAPI> extends Eip1193Provider {

@@ -8,11 +9,11 @@ provider: Web3BaseProvider;

abstract getRPCURL(network: Network, transport: Transport, token: string, host: string): string;
constructor(network: Network, transport: Transport, token: string, host: string);
constructor(network: Network, transport: Transport, token: string, host: string, providerConfigOptions?: HttpProviderOptions | SocketOptions);
request<Method extends Web3APIMethod<API>, ResultType = Web3APIReturnType<API, Method>>(payload: Web3APIPayload<EthExecutionAPI, Method>, requestOptions?: RequestInit): Promise<JsonRpcResponseWithResult<ResultType>>;
getStatus(): Web3ProviderStatus;
supportsSubscriptions(): boolean;
once(type: "disconnect", listener: Web3Eip1193ProviderEventCallback<ProviderRpcError>): void;
once(type: 'disconnect', listener: Web3Eip1193ProviderEventCallback<ProviderRpcError>): void;
once<T = JsonRpcResult>(type: string, listener: Web3Eip1193ProviderEventCallback<ProviderMessage> | Web3ProviderEventCallback<T>): void;
once(type: "connect", listener: Web3Eip1193ProviderEventCallback<ProviderConnectInfo>): void;
once(type: "chainChanged", listener: Web3Eip1193ProviderEventCallback<string>): void;
once(type: "accountsChanged", listener: Web3Eip1193ProviderEventCallback<string[]>): void;
once(type: 'connect', listener: Web3Eip1193ProviderEventCallback<ProviderConnectInfo>): void;
once(type: 'chainChanged', listener: Web3Eip1193ProviderEventCallback<string>): void;
once(type: 'accountsChanged', listener: Web3Eip1193ProviderEventCallback<string[]>): void;
removeAllListeners?(_type: string): void;

@@ -22,13 +23,13 @@ connect(): void;

reset(): void;
on(type: "disconnect", listener: Web3Eip1193ProviderEventCallback<ProviderRpcError>): void;
on(type: 'disconnect', listener: Web3Eip1193ProviderEventCallback<ProviderRpcError>): void;
on<T = JsonRpcResult>(type: string, listener: Web3Eip1193ProviderEventCallback<ProviderMessage> | Web3ProviderMessageEventCallback<T>): void;
on<T = JsonRpcResult>(type: string, listener: Web3Eip1193ProviderEventCallback<ProviderMessage> | Web3ProviderMessageEventCallback<T>): void;
on(type: "connect", listener: Web3Eip1193ProviderEventCallback<ProviderConnectInfo>): void;
on(type: "chainChanged", listener: Web3Eip1193ProviderEventCallback<string>): void;
on(type: "accountsChanged", listener: Web3Eip1193ProviderEventCallback<string[]>): void;
removeListener(type: "disconnect", listener: Web3Eip1193ProviderEventCallback<ProviderRpcError>): void;
on(type: 'connect', listener: Web3Eip1193ProviderEventCallback<ProviderConnectInfo>): void;
on(type: 'chainChanged', listener: Web3Eip1193ProviderEventCallback<string>): void;
on(type: 'accountsChanged', listener: Web3Eip1193ProviderEventCallback<string[]>): void;
removeListener(type: 'disconnect', listener: Web3Eip1193ProviderEventCallback<ProviderRpcError>): void;
removeListener<T = JsonRpcResult>(type: string, listener: Web3Eip1193ProviderEventCallback<ProviderMessage> | Web3ProviderEventCallback<T>): void;
removeListener(type: "connect", listener: Web3Eip1193ProviderEventCallback<ProviderConnectInfo>): void;
removeListener(type: "chainChanged", listener: Web3Eip1193ProviderEventCallback<string>): void;
removeListener(type: "accountsChanged", listener: Web3Eip1193ProviderEventCallback<string[]>): void;
removeListener(type: 'connect', listener: Web3Eip1193ProviderEventCallback<ProviderConnectInfo>): void;
removeListener(type: 'chainChanged', listener: Web3Eip1193ProviderEventCallback<string>): void;
removeListener(type: 'accountsChanged', listener: Web3Eip1193ProviderEventCallback<string[]>): void;
}

@@ -36,2 +36,3 @@ "use strict";

const types_js_1 = require("./types.js");
const errors_js_1 = require("./errors.js");
/*

@@ -45,10 +46,21 @@ This class can be used to create new providers only when there is custom logic required in each Request method like

class Web3ExternalProvider extends web3_utils_1.Eip1193Provider {
constructor(network, transport, token, host) {
constructor(network, transport, token, host, providerConfigOptions) {
super();
if (providerConfigOptions !== undefined &&
transport === types_js_1.Transport.HTTPS &&
!('providerOptions' in providerConfigOptions)) {
throw new errors_js_1.ProviderConfigOptionsError('HTTP Provider');
}
else if (providerConfigOptions !== undefined &&
transport === types_js_1.Transport.WebSocket &&
!('socketOptions' in providerConfigOptions ||
'reconnectOptions' in providerConfigOptions)) {
throw new errors_js_1.ProviderConfigOptionsError('Websocket Provider');
}
this.transport = transport;
if (transport === types_js_1.Transport.HTTPS) {
this.provider = new web3_providers_http_1.default(this.getRPCURL(network, transport, token, host));
this.provider = new web3_providers_http_1.default(this.getRPCURL(network, transport, token, host), providerConfigOptions);
}
else if (transport === types_js_1.Transport.WebSocket) {
this.provider = new web3_providers_ws_1.default(this.getRPCURL(network, transport, token, host));
this.provider = new web3_providers_ws_1.default(this.getRPCURL(network, transport, token, host), providerConfigOptions === null || providerConfigOptions === void 0 ? void 0 : providerConfigOptions.socketOptions, providerConfigOptions === null || providerConfigOptions === void 0 ? void 0 : providerConfigOptions.reconnectOptions);
}

@@ -59,3 +71,3 @@ }

if (this.transport === types_js_1.Transport.HTTPS) {
return yield (this.provider.request(payload, requestOptions));
return (yield this.provider.request(payload, requestOptions));
}

@@ -62,0 +74,0 @@ return this.provider.request(payload);

@@ -17,2 +17,3 @@ /*

*/
/* eslint-disable max-classes-per-file */
import { BaseWeb3Error } from 'web3-errors';

@@ -26,2 +27,10 @@ const ERR_QUICK_NODE_RATE_LIMIT = 1300;

}
const ERR_PROVIDER_CONFIG_OPTIONS = 1301;
export class ProviderConfigOptionsError extends BaseWeb3Error {
constructor(msg) {
super(`Invalid provider config options given for ${msg}`);
this.code = ERR_PROVIDER_CONFIG_OPTIONS;
}
}
/* eslint-enable max-classes-per-file */
//# sourceMappingURL=errors.js.map

@@ -22,3 +22,2 @@ /*

})(Transport || (Transport = {}));
;
export var Network;

@@ -42,3 +41,2 @@ (function (Network) {

})(Network || (Network = {}));
;
//# sourceMappingURL=types.js.map

@@ -26,10 +26,11 @@ /*

};
import { ResponseError } from "web3-errors";
import { Transport, Network } from "./types.js";
import { Web3ExternalProvider } from "./web3_provider.js";
import { QuickNodeRateLimitError } from "./errors.js";
import { ResponseError } from 'web3-errors';
import { Transport, Network } from './types.js';
import { Web3ExternalProvider } from './web3_provider.js';
import { QuickNodeRateLimitError } from './errors.js';
const isValid = (str) => str !== undefined && str.trim().length > 0;
export class QuickNodeProvider extends Web3ExternalProvider {
constructor(network = Network.ETH_MAINNET, transport = Transport.HTTPS, token = "", host = "") {
super(network, transport, token, host);
// eslint-disable-next-line default-param-last
constructor(network = Network.ETH_MAINNET, transport = Transport.HTTPS, token = '', host = '', providerConfigOptions) {
super(network, transport, token, host, providerConfigOptions);
}

@@ -54,43 +55,47 @@ request(payload, requestOptions) {

getRPCURL(network, transport, _token, _host) {
let host = "";
let token = "";
let host = '';
let token = '';
switch (network) {
case Network.ETH_MAINNET:
host = isValid(_host) ? _host : "powerful-holy-bush.quiknode.pro";
token = isValid(_token) ? _token : "3240624a343867035925ff7561eb60dfdba2a668";
host = isValid(_host) ? _host : 'powerful-holy-bush.quiknode.pro';
token = isValid(_token) ? _token : '3240624a343867035925ff7561eb60dfdba2a668';
break;
case Network.ETH_SEPOLIA:
host = isValid(_host) ? _host : "dimensional-fabled-glitter.ethereum-sepolia.quiknode.pro";
token = isValid(_token) ? _token : "382a3b5a4b938f2d6e8686c19af4b22921fde2cd";
host = isValid(_host)
? _host
: 'dimensional-fabled-glitter.ethereum-sepolia.quiknode.pro';
token = isValid(_token) ? _token : '382a3b5a4b938f2d6e8686c19af4b22921fde2cd';
break;
case Network.ETH_HOLESKY:
host = isValid(_host) ? _host : "yolo-morning-card.ethereum-holesky.quiknode.pro";
token = isValid(_token) ? _token : "481ebe70638c4dcf176af617a16d02ab866b9af9";
host = isValid(_host) ? _host : 'yolo-morning-card.ethereum-holesky.quiknode.pro';
token = isValid(_token) ? _token : '481ebe70638c4dcf176af617a16d02ab866b9af9';
break;
case Network.ARBITRUM_MAINNET:
host = isValid(_host) ? _host : "autumn-divine-dinghy.arbitrum-mainnet.quiknode.pro";
token = isValid(_token) ? _token : "a5d7bfbf60b5ae9ce3628e53d69ef50d529e9a8c";
host = isValid(_host)
? _host
: 'autumn-divine-dinghy.arbitrum-mainnet.quiknode.pro';
token = isValid(_token) ? _token : 'a5d7bfbf60b5ae9ce3628e53d69ef50d529e9a8c';
break;
case Network.ARBITRUM_SEPOLIA:
host = isValid(_host) ? _host : "few-patient-pond.arbitrum-sepolia.quiknode.pro";
token = isValid(_token) ? _token : "3be985450970628c860b959c65cd2642dcafe53c";
host = isValid(_host) ? _host : 'few-patient-pond.arbitrum-sepolia.quiknode.pro';
token = isValid(_token) ? _token : '3be985450970628c860b959c65cd2642dcafe53c';
break;
case Network.BNB_MAINNET:
host = isValid(_host) ? _host : "purple-empty-reel.bsc.quiknode.pro";
token = isValid(_token) ? _token : "ebf6c532961e21f092ff2facce1ec4c89c540158";
host = isValid(_host) ? _host : 'purple-empty-reel.bsc.quiknode.pro';
token = isValid(_token) ? _token : 'ebf6c532961e21f092ff2facce1ec4c89c540158';
break;
case Network.BNB_TESTNET:
host = isValid(_host) ? _host : "floral-rough-scion.bsc-testnet.quiknode.pro";
token = isValid(_token) ? _token : "5b297e5acff5f81f4c37ebf6f235f7299b6f9d28";
host = isValid(_host) ? _host : 'floral-rough-scion.bsc-testnet.quiknode.pro';
token = isValid(_token) ? _token : '5b297e5acff5f81f4c37ebf6f235f7299b6f9d28';
break;
case Network.POLYGON_MAINNET:
host = isValid(_host) ? _host : "small-chaotic-moon.matic.quiknode.pro";
token = isValid(_token) ? _token : "847569f8a017e84d985e10d0f44365d965a951f1";
host = isValid(_host) ? _host : 'small-chaotic-moon.matic.quiknode.pro';
token = isValid(_token) ? _token : '847569f8a017e84d985e10d0f44365d965a951f1';
break;
case Network.POLYGON_AMONY:
host = isValid(_host) ? _host : "prettiest-side-shape.matic-amoy.quiknode.pro";
token = isValid(_token) ? _token : "79a9476eea661d4f82de614db1d8a895b14b881c";
host = isValid(_host) ? _host : 'prettiest-side-shape.matic-amoy.quiknode.pro';
token = isValid(_token) ? _token : '79a9476eea661d4f82de614db1d8a895b14b881c';
break;
default:
throw new Error("Network info not avalible.");
throw new Error('Network info not avalible.');
}

@@ -97,0 +102,0 @@ return `${transport}://${host}/${token}`;

@@ -26,6 +26,7 @@ /*

};
import HttpProvider from "web3-providers-http";
import WebSocketProvider from "web3-providers-ws";
import { Eip1193Provider } from "web3-utils";
import { Transport } from "./types.js";
import HttpProvider from 'web3-providers-http';
import WebSocketProvider from 'web3-providers-ws';
import { Eip1193Provider } from 'web3-utils';
import { Transport } from './types.js';
import { ProviderConfigOptionsError } from './errors.js';
/*

@@ -39,10 +40,21 @@ This class can be used to create new providers only when there is custom logic required in each Request method like

export class Web3ExternalProvider extends Eip1193Provider {
constructor(network, transport, token, host) {
constructor(network, transport, token, host, providerConfigOptions) {
super();
if (providerConfigOptions !== undefined &&
transport === Transport.HTTPS &&
!('providerOptions' in providerConfigOptions)) {
throw new ProviderConfigOptionsError('HTTP Provider');
}
else if (providerConfigOptions !== undefined &&
transport === Transport.WebSocket &&
!('socketOptions' in providerConfigOptions ||
'reconnectOptions' in providerConfigOptions)) {
throw new ProviderConfigOptionsError('Websocket Provider');
}
this.transport = transport;
if (transport === Transport.HTTPS) {
this.provider = new HttpProvider(this.getRPCURL(network, transport, token, host));
this.provider = new HttpProvider(this.getRPCURL(network, transport, token, host), providerConfigOptions);
}
else if (transport === Transport.WebSocket) {
this.provider = new WebSocketProvider(this.getRPCURL(network, transport, token, host));
this.provider = new WebSocketProvider(this.getRPCURL(network, transport, token, host), providerConfigOptions === null || providerConfigOptions === void 0 ? void 0 : providerConfigOptions.socketOptions, providerConfigOptions === null || providerConfigOptions === void 0 ? void 0 : providerConfigOptions.reconnectOptions);
}

@@ -53,3 +65,3 @@ }

if (this.transport === Transport.HTTPS) {
return yield (this.provider.request(payload, requestOptions));
return (yield this.provider.request(payload, requestOptions));
}

@@ -56,0 +68,0 @@ return this.provider.request(payload);

@@ -6,2 +6,6 @@ import { BaseWeb3Error } from 'web3-errors';

}
export declare class ProviderConfigOptionsError extends BaseWeb3Error {
code: number;
constructor(msg: string);
}
//# sourceMappingURL=errors.d.ts.map

@@ -0,1 +1,5 @@

/// <reference types="ws" />
/// <reference types="node" />
import { ClientOptions, ClientRequestArgs } from 'web3-providers-ws';
import { ReconnectOptions } from 'web3-utils';
export declare enum Transport {

@@ -22,2 +26,6 @@ HTTPS = "https",

}
export declare type SocketOptions = {
socketOptions?: ClientOptions | ClientRequestArgs;
reconnectOptions?: Partial<ReconnectOptions>;
};
//# sourceMappingURL=types.d.ts.map

@@ -1,6 +0,7 @@

import { EthExecutionAPI, JsonRpcResponseWithResult, Web3APIMethod, Web3APIPayload, Web3APIReturnType, Web3APISpec } from "web3-types";
import { Transport, Network } from "./types.js";
import { Web3ExternalProvider } from "./web3_provider.js";
import { EthExecutionAPI, JsonRpcResponseWithResult, Web3APIMethod, Web3APIPayload, Web3APIReturnType, Web3APISpec } from 'web3-types';
import { HttpProviderOptions } from 'web3-providers-http';
import { Transport, Network, SocketOptions } from './types.js';
import { Web3ExternalProvider } from './web3_provider.js';
export declare class QuickNodeProvider<API extends Web3APISpec = EthExecutionAPI> extends Web3ExternalProvider {
constructor(network?: Network, transport?: Transport, token?: string, host?: string);
constructor(network?: Network, transport?: Transport, token?: string, host?: string, providerConfigOptions?: HttpProviderOptions | SocketOptions);
request<Method extends Web3APIMethod<API>, ResultType = Web3APIReturnType<API, Method>>(payload: Web3APIPayload<EthExecutionAPI, Method>, requestOptions?: RequestInit): Promise<JsonRpcResponseWithResult<ResultType>>;

@@ -7,0 +8,0 @@ getRPCURL(network: Network, transport: Transport, _token: string, _host: string): string;

@@ -1,4 +0,5 @@

import { EthExecutionAPI, JsonRpcResult, ProviderConnectInfo, ProviderMessage, ProviderRpcError, Web3APIMethod, Web3APIPayload, Web3APIReturnType, Web3APISpec, Web3BaseProvider, Web3Eip1193ProviderEventCallback, Web3ProviderEventCallback, Web3ProviderMessageEventCallback, Web3ProviderStatus, JsonRpcResponseWithResult } from "web3-types";
import { Eip1193Provider } from "web3-utils";
import { Transport, Network } from "./types.js";
import { HttpProviderOptions } from 'web3-providers-http';
import { EthExecutionAPI, JsonRpcResult, ProviderConnectInfo, ProviderMessage, ProviderRpcError, Web3APIMethod, Web3APIPayload, Web3APIReturnType, Web3APISpec, Web3BaseProvider, Web3Eip1193ProviderEventCallback, Web3ProviderEventCallback, Web3ProviderMessageEventCallback, Web3ProviderStatus, JsonRpcResponseWithResult } from 'web3-types';
import { Eip1193Provider } from 'web3-utils';
import { Transport, Network, SocketOptions } from './types.js';
export declare abstract class Web3ExternalProvider<API extends Web3APISpec = EthExecutionAPI> extends Eip1193Provider {

@@ -8,11 +9,11 @@ provider: Web3BaseProvider;

abstract getRPCURL(network: Network, transport: Transport, token: string, host: string): string;
constructor(network: Network, transport: Transport, token: string, host: string);
constructor(network: Network, transport: Transport, token: string, host: string, providerConfigOptions?: HttpProviderOptions | SocketOptions);
request<Method extends Web3APIMethod<API>, ResultType = Web3APIReturnType<API, Method>>(payload: Web3APIPayload<EthExecutionAPI, Method>, requestOptions?: RequestInit): Promise<JsonRpcResponseWithResult<ResultType>>;
getStatus(): Web3ProviderStatus;
supportsSubscriptions(): boolean;
once(type: "disconnect", listener: Web3Eip1193ProviderEventCallback<ProviderRpcError>): void;
once(type: 'disconnect', listener: Web3Eip1193ProviderEventCallback<ProviderRpcError>): void;
once<T = JsonRpcResult>(type: string, listener: Web3Eip1193ProviderEventCallback<ProviderMessage> | Web3ProviderEventCallback<T>): void;
once(type: "connect", listener: Web3Eip1193ProviderEventCallback<ProviderConnectInfo>): void;
once(type: "chainChanged", listener: Web3Eip1193ProviderEventCallback<string>): void;
once(type: "accountsChanged", listener: Web3Eip1193ProviderEventCallback<string[]>): void;
once(type: 'connect', listener: Web3Eip1193ProviderEventCallback<ProviderConnectInfo>): void;
once(type: 'chainChanged', listener: Web3Eip1193ProviderEventCallback<string>): void;
once(type: 'accountsChanged', listener: Web3Eip1193ProviderEventCallback<string[]>): void;
removeAllListeners?(_type: string): void;

@@ -22,14 +23,14 @@ connect(): void;

reset(): void;
on(type: "disconnect", listener: Web3Eip1193ProviderEventCallback<ProviderRpcError>): void;
on(type: 'disconnect', listener: Web3Eip1193ProviderEventCallback<ProviderRpcError>): void;
on<T = JsonRpcResult>(type: string, listener: Web3Eip1193ProviderEventCallback<ProviderMessage> | Web3ProviderMessageEventCallback<T>): void;
on<T = JsonRpcResult>(type: string, listener: Web3Eip1193ProviderEventCallback<ProviderMessage> | Web3ProviderMessageEventCallback<T>): void;
on(type: "connect", listener: Web3Eip1193ProviderEventCallback<ProviderConnectInfo>): void;
on(type: "chainChanged", listener: Web3Eip1193ProviderEventCallback<string>): void;
on(type: "accountsChanged", listener: Web3Eip1193ProviderEventCallback<string[]>): void;
removeListener(type: "disconnect", listener: Web3Eip1193ProviderEventCallback<ProviderRpcError>): void;
on(type: 'connect', listener: Web3Eip1193ProviderEventCallback<ProviderConnectInfo>): void;
on(type: 'chainChanged', listener: Web3Eip1193ProviderEventCallback<string>): void;
on(type: 'accountsChanged', listener: Web3Eip1193ProviderEventCallback<string[]>): void;
removeListener(type: 'disconnect', listener: Web3Eip1193ProviderEventCallback<ProviderRpcError>): void;
removeListener<T = JsonRpcResult>(type: string, listener: Web3Eip1193ProviderEventCallback<ProviderMessage> | Web3ProviderEventCallback<T>): void;
removeListener(type: "connect", listener: Web3Eip1193ProviderEventCallback<ProviderConnectInfo>): void;
removeListener(type: "chainChanged", listener: Web3Eip1193ProviderEventCallback<string>): void;
removeListener(type: "accountsChanged", listener: Web3Eip1193ProviderEventCallback<string[]>): void;
removeListener(type: 'connect', listener: Web3Eip1193ProviderEventCallback<ProviderConnectInfo>): void;
removeListener(type: 'chainChanged', listener: Web3Eip1193ProviderEventCallback<string>): void;
removeListener(type: 'accountsChanged', listener: Web3Eip1193ProviderEventCallback<string[]>): void;
}
//# sourceMappingURL=web3_provider.d.ts.map
{
"name": "web3-rpc-providers",
"version": "1.0.0-dev.d9d0391.0+d9d0391",
"version": "1.0.0-dev.dcd9d6a.0+dcd9d6a",
"description": "Web3 Providers package",

@@ -60,10 +60,10 @@ "main": "./lib/commonjs/index.js",

"dependencies": {
"web3-errors": "1.2.2-dev.d9d0391.0+d9d0391",
"web3-providers-http": "4.1.1-dev.d9d0391.0+d9d0391",
"web3-providers-ws": "4.0.9-dev.d9d0391.0+d9d0391",
"web3-types": "1.7.1-dev.d9d0391.0+d9d0391",
"web3-utils": "4.3.2-dev.d9d0391.0+d9d0391",
"web3-validator": "2.0.7-dev.d9d0391.0+d9d0391"
"web3-errors": "1.3.1-dev.dcd9d6a.0+dcd9d6a",
"web3-providers-http": "4.2.1-dev.dcd9d6a.0+dcd9d6a",
"web3-providers-ws": "4.0.9-dev.dcd9d6a.0+dcd9d6a",
"web3-types": "1.8.1-dev.dcd9d6a.0+dcd9d6a",
"web3-utils": "4.3.2-dev.dcd9d6a.0+dcd9d6a",
"web3-validator": "2.0.7-dev.dcd9d6a.0+dcd9d6a"
},
"gitHead": "d9d0391003f2e1d874d39dd43427e1b18b104d8b"
"gitHead": "dcd9d6a0803ad232003cb7e935057711c5b7e381"
}

@@ -14,3 +14,2 @@ <p align="center">

## Installation

@@ -17,0 +16,0 @@

@@ -18,2 +18,4 @@ /*

/* eslint-disable max-classes-per-file */
import { BaseWeb3Error } from 'web3-errors';

@@ -26,4 +28,17 @@

public constructor(error?: Error) {
super(`You've reach the rate limit of free RPC calls from our Partner Quick Nodes. There are two options you can either create a paid Quick Nodes account and get 20% off for 2 months using WEB3JS referral code, or use Free public RPC endpoint.`, error);
super(
`You've reach the rate limit of free RPC calls from our Partner Quick Nodes. There are two options you can either create a paid Quick Nodes account and get 20% off for 2 months using WEB3JS referral code, or use Free public RPC endpoint.`,
error,
);
}
}
}
const ERR_PROVIDER_CONFIG_OPTIONS = 1301;
export class ProviderConfigOptionsError extends BaseWeb3Error {
public code = ERR_PROVIDER_CONFIG_OPTIONS;
public constructor(msg: string) {
super(`Invalid provider config options given for ${msg}`);
}
}
/* eslint-enable max-classes-per-file */

@@ -26,2 +26,2 @@ /*

// default providers
export const mainnet = new QuickNodeProvider();
export const mainnet = new QuickNodeProvider();

@@ -18,28 +18,37 @@ /*

import { ClientOptions, ClientRequestArgs } from 'web3-providers-ws';
import { ReconnectOptions } from 'web3-utils';
export enum Transport {
HTTPS = "https",
WebSocket = "wss"
};
HTTPS = 'https',
WebSocket = 'wss',
}
export enum Network {
ETH_MAINNET = "eth_mainnet",
ETH_GOERLI = "eth_goerli",
ETH_SEPOLIA = "eth_sepolia",
ETH_HOLESKY = "eth_holesky",
ETH_MAINNET = 'eth_mainnet',
ETH_GOERLI = 'eth_goerli',
ETH_SEPOLIA = 'eth_sepolia',
ETH_HOLESKY = 'eth_holesky',
POLYGON_MAINNET= "polygon_mainnet",
POLYGON_MUMBAI= "polygon_mumbai",
POLYGON_AMONY= "polygon_amony",
POLYGON_MAINNET = 'polygon_mainnet',
POLYGON_MUMBAI = 'polygon_mumbai',
POLYGON_AMONY = 'polygon_amony',
ARBITRUM_MAINNET = "arbitrum_mainnet",
ARBITRUM_SEPOLIA = "arbitrum_sepolia",
ARBITRUM_MAINNET = 'arbitrum_mainnet',
ARBITRUM_SEPOLIA = 'arbitrum_sepolia',
BASE_MAINNET = "base_mainnet",
BASE_SEPOLIA = "base_sepolia",
BASE_MAINNET = 'base_mainnet',
BASE_SEPOLIA = 'base_sepolia',
OPTIMISM_MAINNET = "optimism_mainnet",
OPTIMISM_SEPOLIA = "optimism_sepolia",
OPTIMISM_MAINNET = 'optimism_mainnet',
OPTIMISM_SEPOLIA = 'optimism_sepolia',
BNB_MAINNET = "bnb_mainnet",
BNB_TESTNET = "bnb_testnet"
};
BNB_MAINNET = 'bnb_mainnet',
BNB_TESTNET = 'bnb_testnet',
}
// Combining the ws types
export type SocketOptions = {
socketOptions?: ClientOptions | ClientRequestArgs;
reconnectOptions?: Partial<ReconnectOptions>;
};

@@ -18,7 +18,15 @@ /*

import { EthExecutionAPI, JsonRpcResponseWithResult, Web3APIMethod, Web3APIPayload, Web3APIReturnType, Web3APISpec } from "web3-types";
import { ResponseError } from "web3-errors";
import { Transport, Network } from "./types.js";
import { Web3ExternalProvider } from "./web3_provider.js";
import { QuickNodeRateLimitError } from "./errors.js";
import {
EthExecutionAPI,
JsonRpcResponseWithResult,
Web3APIMethod,
Web3APIPayload,
Web3APIReturnType,
Web3APISpec,
} from 'web3-types';
import { ResponseError } from 'web3-errors';
import { HttpProviderOptions } from 'web3-providers-http';
import { Transport, Network, SocketOptions } from './types.js';
import { Web3ExternalProvider } from './web3_provider.js';
import { QuickNodeRateLimitError } from './errors.js';

@@ -28,89 +36,87 @@ const isValid = (str: string) => str !== undefined && str.trim().length > 0;

export class QuickNodeProvider<
API extends Web3APISpec = EthExecutionAPI,
API extends Web3APISpec = EthExecutionAPI,
> extends Web3ExternalProvider {
// eslint-disable-next-line default-param-last
public constructor(
network: Network = Network.ETH_MAINNET,
transport: Transport = Transport.HTTPS,
token = '',
host = '',
providerConfigOptions?: HttpProviderOptions | SocketOptions,
) {
super(network, transport, token, host, providerConfigOptions);
}
public constructor(
network: Network = Network.ETH_MAINNET,
transport: Transport = Transport.HTTPS,
token = "",
host = "") {
public async request<
Method extends Web3APIMethod<API>,
ResultType = Web3APIReturnType<API, Method>,
>(
payload: Web3APIPayload<EthExecutionAPI, Method>,
requestOptions?: RequestInit,
): Promise<JsonRpcResponseWithResult<ResultType>> {
try {
return await super.request(payload, requestOptions);
} catch (error) {
if (error instanceof ResponseError && error.statusCode === 429) {
throw new QuickNodeRateLimitError(error);
}
throw error;
}
}
super(network, transport, token, host);
// eslint-disable-next-line class-methods-use-this
public getRPCURL(network: Network, transport: Transport, _token: string, _host: string) {
let host = '';
let token = '';
}
switch (network) {
case Network.ETH_MAINNET:
host = isValid(_host) ? _host : 'powerful-holy-bush.quiknode.pro';
token = isValid(_token) ? _token : '3240624a343867035925ff7561eb60dfdba2a668';
break;
case Network.ETH_SEPOLIA:
host = isValid(_host)
? _host
: 'dimensional-fabled-glitter.ethereum-sepolia.quiknode.pro';
token = isValid(_token) ? _token : '382a3b5a4b938f2d6e8686c19af4b22921fde2cd';
break;
case Network.ETH_HOLESKY:
host = isValid(_host) ? _host : 'yolo-morning-card.ethereum-holesky.quiknode.pro';
token = isValid(_token) ? _token : '481ebe70638c4dcf176af617a16d02ab866b9af9';
break;
public async request<
Method extends Web3APIMethod<API>,
ResultType = Web3APIReturnType<API, Method>,
>(
payload: Web3APIPayload<EthExecutionAPI, Method>,
requestOptions?: RequestInit,
): Promise<JsonRpcResponseWithResult<ResultType>> {
case Network.ARBITRUM_MAINNET:
host = isValid(_host)
? _host
: 'autumn-divine-dinghy.arbitrum-mainnet.quiknode.pro';
token = isValid(_token) ? _token : 'a5d7bfbf60b5ae9ce3628e53d69ef50d529e9a8c';
break;
case Network.ARBITRUM_SEPOLIA:
host = isValid(_host) ? _host : 'few-patient-pond.arbitrum-sepolia.quiknode.pro';
token = isValid(_token) ? _token : '3be985450970628c860b959c65cd2642dcafe53c';
break;
try {
return await super.request(payload, requestOptions);
} catch (error) {
if (error instanceof ResponseError && error.statusCode === 429){
throw new QuickNodeRateLimitError(error);
}
throw error;
}
}
case Network.BNB_MAINNET:
host = isValid(_host) ? _host : 'purple-empty-reel.bsc.quiknode.pro';
token = isValid(_token) ? _token : 'ebf6c532961e21f092ff2facce1ec4c89c540158';
break;
case Network.BNB_TESTNET:
host = isValid(_host) ? _host : 'floral-rough-scion.bsc-testnet.quiknode.pro';
token = isValid(_token) ? _token : '5b297e5acff5f81f4c37ebf6f235f7299b6f9d28';
break;
// eslint-disable-next-line class-methods-use-this
public getRPCURL(network: Network,
transport: Transport,
_token: string,
_host: string) {
let host = "";
let token = "";
case Network.POLYGON_MAINNET:
host = isValid(_host) ? _host : 'small-chaotic-moon.matic.quiknode.pro';
token = isValid(_token) ? _token : '847569f8a017e84d985e10d0f44365d965a951f1';
break;
case Network.POLYGON_AMONY:
host = isValid(_host) ? _host : 'prettiest-side-shape.matic-amoy.quiknode.pro';
token = isValid(_token) ? _token : '79a9476eea661d4f82de614db1d8a895b14b881c';
break;
default:
throw new Error('Network info not avalible.');
}
switch (network) {
case Network.ETH_MAINNET:
host = isValid(_host) ? _host : "powerful-holy-bush.quiknode.pro";
token = isValid(_token) ? _token : "3240624a343867035925ff7561eb60dfdba2a668";
break;
case Network.ETH_SEPOLIA:
host = isValid(_host) ? _host : "dimensional-fabled-glitter.ethereum-sepolia.quiknode.pro";
token = isValid(_token) ? _token : "382a3b5a4b938f2d6e8686c19af4b22921fde2cd";
break
case Network.ETH_HOLESKY:
host = isValid(_host) ? _host : "yolo-morning-card.ethereum-holesky.quiknode.pro";
token = isValid(_token) ? _token : "481ebe70638c4dcf176af617a16d02ab866b9af9";
break;
case Network.ARBITRUM_MAINNET:
host = isValid(_host) ? _host : "autumn-divine-dinghy.arbitrum-mainnet.quiknode.pro";
token = isValid(_token) ? _token : "a5d7bfbf60b5ae9ce3628e53d69ef50d529e9a8c";
break;
case Network.ARBITRUM_SEPOLIA:
host = isValid(_host) ? _host : "few-patient-pond.arbitrum-sepolia.quiknode.pro";
token = isValid(_token) ? _token : "3be985450970628c860b959c65cd2642dcafe53c";
break;
case Network.BNB_MAINNET:
host = isValid(_host) ? _host : "purple-empty-reel.bsc.quiknode.pro";
token = isValid(_token) ? _token : "ebf6c532961e21f092ff2facce1ec4c89c540158";
break;
case Network.BNB_TESTNET:
host = isValid(_host) ? _host : "floral-rough-scion.bsc-testnet.quiknode.pro";
token = isValid(_token) ? _token : "5b297e5acff5f81f4c37ebf6f235f7299b6f9d28";
break;
case Network.POLYGON_MAINNET:
host = isValid(_host) ? _host : "small-chaotic-moon.matic.quiknode.pro";
token = isValid(_token) ? _token : "847569f8a017e84d985e10d0f44365d965a951f1";
break;
case Network.POLYGON_AMONY:
host = isValid(_host) ? _host : "prettiest-side-shape.matic-amoy.quiknode.pro";
token = isValid(_token) ? _token : "79a9476eea661d4f82de614db1d8a895b14b881c";
break;
default:
throw new Error("Network info not avalible.");
}
return `${transport}://${host}/${token}`;
}
return `${transport}://${host}/${token}`;
}
}

@@ -18,15 +18,24 @@ /*

import HttpProvider from "web3-providers-http";
import WebSocketProvider from "web3-providers-ws";
import HttpProvider, { HttpProviderOptions } from 'web3-providers-http';
import WebSocketProvider from 'web3-providers-ws';
import {
EthExecutionAPI, JsonRpcResult, ProviderConnectInfo, ProviderMessage,
ProviderRpcError, Web3APIMethod, Web3APIPayload, Web3APIReturnType, Web3APISpec, Web3BaseProvider,
Web3Eip1193ProviderEventCallback,
Web3ProviderEventCallback,
Web3ProviderMessageEventCallback,
Web3ProviderStatus,
JsonRpcResponseWithResult,
} from "web3-types";
import { Eip1193Provider } from "web3-utils";
import { Transport, Network } from "./types.js";
EthExecutionAPI,
JsonRpcResult,
ProviderConnectInfo,
ProviderMessage,
ProviderRpcError,
Web3APIMethod,
Web3APIPayload,
Web3APIReturnType,
Web3APISpec,
Web3BaseProvider,
Web3Eip1193ProviderEventCallback,
Web3ProviderEventCallback,
Web3ProviderMessageEventCallback,
Web3ProviderStatus,
JsonRpcResponseWithResult,
} from 'web3-types';
import { Eip1193Provider } from 'web3-utils';
import { Transport, Network, SocketOptions } from './types.js';
import { ProviderConfigOptionsError } from './errors.js';

@@ -42,97 +51,165 @@ /*

export abstract class Web3ExternalProvider<
API extends Web3APISpec = EthExecutionAPI,
API extends Web3APISpec = EthExecutionAPI,
> extends Eip1193Provider {
public provider!: Web3BaseProvider;
public readonly transport: Transport;
public provider!: Web3BaseProvider;
public readonly transport: Transport;
public abstract getRPCURL(
network: Network,
transport: Transport,
token: string,
host: string,
): string;
public abstract getRPCURL(network: Network, transport: Transport, token: string, host: string): string;
public constructor(
network: Network,
transport: Transport,
token: string,
host: string,
providerConfigOptions?: HttpProviderOptions | SocketOptions,
) {
super();
public constructor(
network: Network,
transport: Transport,
token: string,
host: string) {
if (
providerConfigOptions !== undefined &&
transport === Transport.HTTPS &&
!('providerOptions' in providerConfigOptions)
) {
throw new ProviderConfigOptionsError('HTTP Provider');
} else if (
providerConfigOptions !== undefined &&
transport === Transport.WebSocket &&
!(
'socketOptions' in providerConfigOptions ||
'reconnectOptions' in providerConfigOptions
)
) {
throw new ProviderConfigOptionsError('Websocket Provider');
}
super();
this.transport = transport;
if (transport === Transport.HTTPS) {
this.provider = new HttpProvider(
this.getRPCURL(network, transport, token, host),
providerConfigOptions as HttpProviderOptions,
);
} else if (transport === Transport.WebSocket) {
this.provider = new WebSocketProvider(
this.getRPCURL(network, transport, token, host),
(providerConfigOptions as SocketOptions)?.socketOptions,
(providerConfigOptions as SocketOptions)?.reconnectOptions,
);
}
}
this.transport = transport;
if (transport === Transport.HTTPS) {
this.provider = new HttpProvider(this.getRPCURL(network, transport, token, host));
}
else if (transport === Transport.WebSocket) {
this.provider = new WebSocketProvider(this.getRPCURL(network, transport, token, host));
}
}
public async request<
Method extends Web3APIMethod<API>,
ResultType = Web3APIReturnType<API, Method>,
>(
payload: Web3APIPayload<EthExecutionAPI, Method>,
requestOptions?: RequestInit,
): Promise<JsonRpcResponseWithResult<ResultType>> {
if (this.transport === Transport.HTTPS) {
return (await (this.provider as HttpProvider).request(
payload,
requestOptions,
)) as unknown as JsonRpcResponseWithResult<ResultType>;
}
public async request<
Method extends Web3APIMethod<API>,
ResultType = Web3APIReturnType<API, Method>,
>(
payload: Web3APIPayload<EthExecutionAPI, Method>,
requestOptions?: RequestInit,
): Promise<JsonRpcResponseWithResult<ResultType>> {
return (this.provider as WebSocketProvider).request(payload);
}
if (this.transport === Transport.HTTPS) {
return await ((this.provider as HttpProvider).request(payload, requestOptions)) as unknown as JsonRpcResponseWithResult<ResultType>;
}
public getStatus(): Web3ProviderStatus {
return this.provider.getStatus();
}
public supportsSubscriptions(): boolean {
return this.provider.supportsSubscriptions();
}
public once(
type: 'disconnect',
listener: Web3Eip1193ProviderEventCallback<ProviderRpcError>,
): void;
public once<T = JsonRpcResult>(
type: string,
listener: Web3Eip1193ProviderEventCallback<ProviderMessage> | Web3ProviderEventCallback<T>,
): void;
public once(
type: 'connect',
listener: Web3Eip1193ProviderEventCallback<ProviderConnectInfo>,
): void;
public once(type: 'chainChanged', listener: Web3Eip1193ProviderEventCallback<string>): void;
public once(
type: 'accountsChanged',
listener: Web3Eip1193ProviderEventCallback<string[]>,
): void;
public once(_type: string, _listener: unknown): void {
if (this.provider?.once)
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
this.provider.once(_type, _listener as any);
}
public removeAllListeners?(_type: string): void {
if (this.provider?.removeAllListeners) this.provider.removeAllListeners(_type);
}
public connect(): void {
if (this.provider?.connect) this.provider.connect();
}
public disconnect(_code?: number | undefined, _data?: string | undefined): void {
if (this.provider?.disconnect) this.provider.disconnect(_code, _data);
}
public reset(): void {
if (this.provider?.reset) this.provider.reset();
}
return (this.provider as WebSocketProvider).request(payload);
}
public getStatus(): Web3ProviderStatus {
return this.provider.getStatus();
}
public supportsSubscriptions(): boolean {
return this.provider.supportsSubscriptions();
}
public once(type: "disconnect", listener: Web3Eip1193ProviderEventCallback<ProviderRpcError>): void;
public once<T = JsonRpcResult>(type: string, listener: Web3Eip1193ProviderEventCallback<ProviderMessage> | Web3ProviderEventCallback<T>): void;
public once(type: "connect", listener: Web3Eip1193ProviderEventCallback<ProviderConnectInfo>): void;
public once(type: "chainChanged", listener: Web3Eip1193ProviderEventCallback<string>): void;
public once(type: "accountsChanged", listener: Web3Eip1193ProviderEventCallback<string[]>): void;
public once(_type: string, _listener: unknown): void {
if (this.provider?.once)
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
this.provider.once(_type, _listener as any);
}
public removeAllListeners?(_type: string): void {
if (this.provider?.removeAllListeners)
this.provider.removeAllListeners(_type);
}
public connect(): void {
if (this.provider?.connect)
this.provider.connect();
}
public disconnect(_code?: number | undefined, _data?: string | undefined): void {
if (this.provider?.disconnect)
this.provider.disconnect(_code, _data);
}
public reset(): void {
if (this.provider?.reset)
this.provider.reset();
}
public on(type: "disconnect", listener: Web3Eip1193ProviderEventCallback<ProviderRpcError>): void;
public on<T = JsonRpcResult>(type: string, listener: Web3Eip1193ProviderEventCallback<ProviderMessage> | Web3ProviderMessageEventCallback<T>): void;
public on<T = JsonRpcResult>(type: string, listener: Web3Eip1193ProviderEventCallback<ProviderMessage> | Web3ProviderMessageEventCallback<T>): void;
public on(type: "connect", listener: Web3Eip1193ProviderEventCallback<ProviderConnectInfo>): void;
public on(type: "chainChanged", listener: Web3Eip1193ProviderEventCallback<string>): void;
public on(type: "accountsChanged", listener: Web3Eip1193ProviderEventCallback<string[]>): void;
public on(_type: unknown, _listener: unknown): void {
if (this.provider)
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
this.provider.on(_type as any, _listener as any);
}
public removeListener(type: "disconnect", listener: Web3Eip1193ProviderEventCallback<ProviderRpcError>): void;
public removeListener<T = JsonRpcResult>(type: string, listener: Web3Eip1193ProviderEventCallback<ProviderMessage> | Web3ProviderEventCallback<T>): void;
public removeListener(type: "connect", listener: Web3Eip1193ProviderEventCallback<ProviderConnectInfo>): void;
public removeListener(type: "chainChanged", listener: Web3Eip1193ProviderEventCallback<string>): void;
public removeListener(type: "accountsChanged", listener: Web3Eip1193ProviderEventCallback<string[]>): void;
public removeListener(_type: unknown, _listener: unknown): void {
if (this.provider)
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
this.provider.removeListener(_type as any, _listener as any);
}
}
public on(
type: 'disconnect',
listener: Web3Eip1193ProviderEventCallback<ProviderRpcError>,
): void;
public on<T = JsonRpcResult>(
type: string,
listener:
| Web3Eip1193ProviderEventCallback<ProviderMessage>
| Web3ProviderMessageEventCallback<T>,
): void;
public on<T = JsonRpcResult>(
type: string,
listener:
| Web3Eip1193ProviderEventCallback<ProviderMessage>
| Web3ProviderMessageEventCallback<T>,
): void;
public on(
type: 'connect',
listener: Web3Eip1193ProviderEventCallback<ProviderConnectInfo>,
): void;
public on(type: 'chainChanged', listener: Web3Eip1193ProviderEventCallback<string>): void;
public on(type: 'accountsChanged', listener: Web3Eip1193ProviderEventCallback<string[]>): void;
public on(_type: unknown, _listener: unknown): void {
if (this.provider)
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
this.provider.on(_type as any, _listener as any);
}
public removeListener(
type: 'disconnect',
listener: Web3Eip1193ProviderEventCallback<ProviderRpcError>,
): void;
public removeListener<T = JsonRpcResult>(
type: string,
listener: Web3Eip1193ProviderEventCallback<ProviderMessage> | Web3ProviderEventCallback<T>,
): void;
public removeListener(
type: 'connect',
listener: Web3Eip1193ProviderEventCallback<ProviderConnectInfo>,
): void;
public removeListener(
type: 'chainChanged',
listener: Web3Eip1193ProviderEventCallback<string>,
): void;
public removeListener(
type: 'accountsChanged',
listener: Web3Eip1193ProviderEventCallback<string[]>,
): void;
public removeListener(_type: unknown, _listener: unknown): void {
if (this.provider)
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
this.provider.removeListener(_type as any, _listener as any);
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc