web3-rpc-providers
Advanced tools
Comparing version 1.0.0-dev.75df267.0 to 1.0.0-dev.76c468a.0
@@ -38,3 +38,3 @@ "use strict"; | ||
exports.ProviderConfigOptionsError = ProviderConfigOptionsError; | ||
/* eslint-enable max-classes-per-file */ | ||
/* eslint-enable max-classes-per-file */ | ||
//# sourceMappingURL=errors.js.map |
/// <reference types="ws" /> | ||
/// <reference types="node" /> | ||
import { ClientOptions, ClientRequestArgs } from "web3-providers-ws"; | ||
import { ClientOptions, ClientRequestArgs } from 'web3-providers-ws'; | ||
import { ReconnectOptions } from 'web3-utils'; | ||
@@ -5,0 +5,0 @@ export declare enum Transport { |
@@ -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,5 +0,5 @@ | ||
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"; | ||
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 { | ||
@@ -6,0 +6,0 @@ constructor(network?: Network, transport?: Transport, token?: string, host?: string, providerConfigOptions?: HttpProviderOptions | SocketOptions); |
@@ -36,3 +36,3 @@ "use strict"; | ||
// eslint-disable-next-line default-param-last | ||
constructor(network = types_js_1.Network.ETH_MAINNET, transport = types_js_1.Transport.HTTPS, token = "", host = "", providerConfigOptions) { | ||
constructor(network = types_js_1.Network.ETH_MAINNET, transport = types_js_1.Transport.HTTPS, token = '', host = '', providerConfigOptions) { | ||
super(network, transport, token, host, providerConfigOptions); | ||
@@ -58,43 +58,47 @@ } | ||
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.'); | ||
} | ||
@@ -101,0 +105,0 @@ return `${transport}://${host}/${token}`; |
@@ -1,5 +0,5 @@ | ||
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"; | ||
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 { | ||
@@ -13,7 +13,7 @@ provider: Web3BaseProvider; | ||
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; | ||
@@ -23,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; | ||
} |
@@ -50,3 +50,3 @@ "use strict"; | ||
!('providerOptions' in providerConfigOptions)) { | ||
throw new errors_js_1.ProviderConfigOptionsError("HTTP Provider"); | ||
throw new errors_js_1.ProviderConfigOptionsError('HTTP Provider'); | ||
} | ||
@@ -57,3 +57,3 @@ else if (providerConfigOptions !== undefined && | ||
'reconnectOptions' in providerConfigOptions)) { | ||
throw new errors_js_1.ProviderConfigOptionsError("Websocket Provider"); | ||
throw new errors_js_1.ProviderConfigOptionsError('Websocket Provider'); | ||
} | ||
@@ -71,3 +71,3 @@ this.transport = transport; | ||
if (this.transport === types_js_1.Transport.HTTPS) { | ||
return yield (this.provider.request(payload, requestOptions)); | ||
return (yield this.provider.request(payload, requestOptions)); | ||
} | ||
@@ -74,0 +74,0 @@ return this.provider.request(payload); |
@@ -33,3 +33,3 @@ /* | ||
} | ||
/* eslint-enable max-classes-per-file */ | ||
/* 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,10 @@ /* | ||
}; | ||
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 { | ||
// eslint-disable-next-line default-param-last | ||
constructor(network = Network.ETH_MAINNET, transport = Transport.HTTPS, token = "", host = "", providerConfigOptions) { | ||
constructor(network = Network.ETH_MAINNET, transport = Transport.HTTPS, token = '', host = '', providerConfigOptions) { | ||
super(network, transport, token, host, providerConfigOptions); | ||
@@ -55,43 +55,47 @@ } | ||
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.'); | ||
} | ||
@@ -98,0 +102,0 @@ return `${transport}://${host}/${token}`; |
@@ -26,7 +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 { ProviderConfigOptionsError } from "./errors.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'; | ||
/* | ||
@@ -45,3 +45,3 @@ This class can be used to create new providers only when there is custom logic required in each Request method like | ||
!('providerOptions' in providerConfigOptions)) { | ||
throw new ProviderConfigOptionsError("HTTP Provider"); | ||
throw new ProviderConfigOptionsError('HTTP Provider'); | ||
} | ||
@@ -52,3 +52,3 @@ else if (providerConfigOptions !== undefined && | ||
'reconnectOptions' in providerConfigOptions)) { | ||
throw new ProviderConfigOptionsError("Websocket Provider"); | ||
throw new ProviderConfigOptionsError('Websocket Provider'); | ||
} | ||
@@ -66,3 +66,3 @@ this.transport = transport; | ||
if (this.transport === Transport.HTTPS) { | ||
return yield (this.provider.request(payload, requestOptions)); | ||
return (yield this.provider.request(payload, requestOptions)); | ||
} | ||
@@ -69,0 +69,0 @@ return this.provider.request(payload); |
/// <reference types="ws" /> | ||
/// <reference types="node" /> | ||
import { ClientOptions, ClientRequestArgs } from "web3-providers-ws"; | ||
import { ClientOptions, ClientRequestArgs } from 'web3-providers-ws'; | ||
import { ReconnectOptions } from 'web3-utils'; | ||
@@ -5,0 +5,0 @@ export declare enum Transport { |
@@ -1,5 +0,5 @@ | ||
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"; | ||
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 { | ||
@@ -6,0 +6,0 @@ constructor(network?: Network, transport?: Transport, token?: string, host?: string, providerConfigOptions?: HttpProviderOptions | SocketOptions); |
@@ -1,5 +0,5 @@ | ||
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"; | ||
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 { | ||
@@ -13,7 +13,7 @@ provider: Web3BaseProvider; | ||
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; | ||
@@ -23,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.75df267.0+75df267", | ||
"version": "1.0.0-dev.76c468a.0+76c468a", | ||
"description": "Web3 Providers package", | ||
@@ -60,10 +60,10 @@ "main": "./lib/commonjs/index.js", | ||
"dependencies": { | ||
"web3-errors": "1.3.1-dev.75df267.0+75df267", | ||
"web3-providers-http": "4.2.1-dev.75df267.0+75df267", | ||
"web3-providers-ws": "4.0.9-dev.75df267.0+75df267", | ||
"web3-types": "1.7.1-dev.75df267.0+75df267", | ||
"web3-utils": "4.3.2-dev.75df267.0+75df267", | ||
"web3-validator": "2.0.7-dev.75df267.0+75df267" | ||
"web3-errors": "1.3.1-dev.76c468a.0+76c468a", | ||
"web3-providers-http": "4.2.1-dev.76c468a.0+76c468a", | ||
"web3-providers-ws": "4.0.9-dev.76c468a.0+76c468a", | ||
"web3-types": "1.8.1-dev.76c468a.0+76c468a", | ||
"web3-utils": "4.3.2-dev.76c468a.0+76c468a", | ||
"web3-validator": "2.0.7-dev.76c468a.0+76c468a" | ||
}, | ||
"gitHead": "75df2677caa955ed3d62eac18e3c6a1fad2103b7" | ||
"gitHead": "76c468ad490ba7a50229acb12690e0239870d8fb" | ||
} |
@@ -14,3 +14,2 @@ <p align="center"> | ||
## Installation | ||
@@ -17,0 +16,0 @@ |
@@ -27,3 +27,6 @@ /* | ||
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, | ||
); | ||
} | ||
@@ -40,2 +43,2 @@ } | ||
} | ||
/* eslint-enable max-classes-per-file */ | ||
/* eslint-enable max-classes-per-file */ |
@@ -26,2 +26,2 @@ /* | ||
// default providers | ||
export const mainnet = new QuickNodeProvider(); | ||
export const mainnet = new QuickNodeProvider(); |
@@ -18,37 +18,37 @@ /* | ||
import {ClientOptions, ClientRequestArgs} from "web3-providers-ws"; | ||
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>; | ||
}; | ||
socketOptions?: ClientOptions | ClientRequestArgs; | ||
reconnectOptions?: Partial<ReconnectOptions>; | ||
}; |
@@ -18,8 +18,15 @@ /* | ||
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"; | ||
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'; | ||
@@ -29,86 +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); | ||
} | ||
// eslint-disable-next-line default-param-last | ||
public constructor( network: Network = Network.ETH_MAINNET, transport: Transport = Transport.HTTPS, token = "", host = "", providerConfigOptions?: HttpProviderOptions | SocketOptions) { | ||
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, providerConfigOptions); | ||
// 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,16 +18,24 @@ /* | ||
import HttpProvider, { HttpProviderOptions } 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, SocketOptions } from "./types.js"; | ||
import { ProviderConfigOptionsError } from "./errors.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'; | ||
@@ -43,118 +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, | ||
providerConfigOptions?: HttpProviderOptions | SocketOptions) { | ||
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, | ||
); | ||
} | ||
} | ||
if(providerConfigOptions!== undefined && | ||
transport === Transport.HTTPS && | ||
!('providerOptions' in providerConfigOptions)){ | ||
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>; | ||
} | ||
throw new ProviderConfigOptionsError("HTTP Provider"); | ||
} | ||
else if(providerConfigOptions!== undefined && | ||
transport === Transport.WebSocket && | ||
!( 'socketOptions' in providerConfigOptions || | ||
'reconnectOptions' in providerConfigOptions | ||
)){ | ||
throw new ProviderConfigOptionsError("Websocket Provider"); | ||
} | ||
return (this.provider as WebSocketProvider).request(payload); | ||
} | ||
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); | ||
} | ||
} | ||
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 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>; | ||
} | ||
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
1193
82220
58