web3-rpc-providers
Advanced tools
Comparing version 1.0.0-dev.1436228.0 to 1.0.0-dev.89711ab.0
@@ -1,2 +0,2 @@ | ||
import { EthExecutionAPI, JsonRpcResult, ProviderConnectInfo, ProviderMessage, ProviderRpcError, Web3APIMethod, Web3APIPayload, Web3APIReturnType, Web3APISpec, Web3BaseProvider, Web3Eip1193ProviderEventCallback, Web3ProviderEventCallback, Web3ProviderMessageEventCallback, Web3ProviderStatus } from "web3-types"; | ||
import { EthExecutionAPI, JsonRpcResult, ProviderConnectInfo, ProviderMessage, ProviderRpcError, Web3APIMethod, Web3APIPayload, Web3APIReturnType, Web3APISpec, Web3BaseProvider, Web3Eip1193ProviderEventCallback, Web3ProviderEventCallback, Web3ProviderMessageEventCallback, Web3ProviderStatus, JsonRpcResponseWithResult } from "web3-types"; | ||
import { Eip1193Provider } from "web3-utils"; | ||
@@ -9,3 +9,3 @@ import { Transport, Network } from "./types.js"; | ||
constructor(network: Network, transport: Transport, token: string, host: string); | ||
request<Method extends Web3APIMethod<API>, ResultType = Web3APIReturnType<API, Method>>(payload: Web3APIPayload<EthExecutionAPI, Method>, requestOptions?: RequestInit): Promise<ResultType>; | ||
request<Method extends Web3APIMethod<API>, ResultType = Web3APIReturnType<API, Method>>(payload: Web3APIPayload<EthExecutionAPI, Method>, requestOptions?: RequestInit): Promise<JsonRpcResponseWithResult<ResultType>>; | ||
getStatus(): Web3ProviderStatus; | ||
@@ -12,0 +12,0 @@ supportsSubscriptions(): boolean; |
@@ -34,4 +34,6 @@ "use strict"; | ||
const web3_providers_ws_1 = __importDefault(require("web3-providers-ws")); | ||
const web3_validator_1 = require("web3-validator"); | ||
const web3_utils_1 = require("web3-utils"); | ||
const types_js_1 = require("./types.js"); | ||
const errors_js_1 = require("./errors.js"); | ||
/* | ||
@@ -58,5 +60,10 @@ This class can be used to create new providers only when there is custom logic required in each Request method like | ||
if (this.transport === types_js_1.Transport.HTTPS) { | ||
return (this.provider.request(payload, requestOptions)); | ||
const res = yield (this.provider.request(payload, requestOptions)); | ||
if (typeof res === 'object' && !(0, web3_validator_1.isNullish)(res) && 'error' in res && !(0, web3_validator_1.isNullish)(res.error) && 'code' in res.error && res.error.code === 429) { | ||
// rate limiting error by quicknode; | ||
throw new errors_js_1.QuickNodeRateLimitError(); | ||
} | ||
return res; | ||
} | ||
return (this.provider.request(payload)); | ||
return this.provider.request(payload); | ||
}); | ||
@@ -63,0 +70,0 @@ } |
@@ -28,4 +28,6 @@ /* | ||
import WebSocketProvider from "web3-providers-ws"; | ||
import { isNullish } from "web3-validator"; | ||
import { Eip1193Provider } from "web3-utils"; | ||
import { Transport } from "./types.js"; | ||
import { QuickNodeRateLimitError } from './errors.js'; | ||
/* | ||
@@ -52,5 +54,10 @@ This class can be used to create new providers only when there is custom logic required in each Request method like | ||
if (this.transport === Transport.HTTPS) { | ||
return (this.provider.request(payload, requestOptions)); | ||
const res = yield (this.provider.request(payload, requestOptions)); | ||
if (typeof res === 'object' && !isNullish(res) && 'error' in res && !isNullish(res.error) && 'code' in res.error && res.error.code === 429) { | ||
// rate limiting error by quicknode; | ||
throw new QuickNodeRateLimitError(); | ||
} | ||
return res; | ||
} | ||
return (this.provider.request(payload)); | ||
return this.provider.request(payload); | ||
}); | ||
@@ -57,0 +64,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { EthExecutionAPI, JsonRpcResult, ProviderConnectInfo, ProviderMessage, ProviderRpcError, Web3APIMethod, Web3APIPayload, Web3APIReturnType, Web3APISpec, Web3BaseProvider, Web3Eip1193ProviderEventCallback, Web3ProviderEventCallback, Web3ProviderMessageEventCallback, Web3ProviderStatus } from "web3-types"; | ||
import { EthExecutionAPI, JsonRpcResult, ProviderConnectInfo, ProviderMessage, ProviderRpcError, Web3APIMethod, Web3APIPayload, Web3APIReturnType, Web3APISpec, Web3BaseProvider, Web3Eip1193ProviderEventCallback, Web3ProviderEventCallback, Web3ProviderMessageEventCallback, Web3ProviderStatus, JsonRpcResponseWithResult } from "web3-types"; | ||
import { Eip1193Provider } from "web3-utils"; | ||
@@ -9,3 +9,3 @@ import { Transport, Network } from "./types.js"; | ||
constructor(network: Network, transport: Transport, token: string, host: string); | ||
request<Method extends Web3APIMethod<API>, ResultType = Web3APIReturnType<API, Method>>(payload: Web3APIPayload<EthExecutionAPI, Method>, requestOptions?: RequestInit): Promise<ResultType>; | ||
request<Method extends Web3APIMethod<API>, ResultType = Web3APIReturnType<API, Method>>(payload: Web3APIPayload<EthExecutionAPI, Method>, requestOptions?: RequestInit): Promise<JsonRpcResponseWithResult<ResultType>>; | ||
getStatus(): Web3ProviderStatus; | ||
@@ -12,0 +12,0 @@ supportsSubscriptions(): boolean; |
{ | ||
"name": "web3-rpc-providers", | ||
"version": "1.0.0-dev.1436228.0+1436228", | ||
"version": "1.0.0-dev.89711ab.0+89711ab", | ||
"description": "Web3 Providers package", | ||
@@ -59,8 +59,10 @@ "main": "./lib/commonjs/index.js", | ||
"dependencies": { | ||
"web3-providers-http": "4.1.1-dev.1436228.0+1436228", | ||
"web3-providers-ws": "4.0.8-dev.1436228.0+1436228", | ||
"web3-types": "1.7.1-dev.1436228.0+1436228", | ||
"web3-utils": "4.3.1-dev.1436228.0+1436228" | ||
"web3-errors": "1.2.1-dev.89711ab.0+89711ab", | ||
"web3-providers-http": "4.1.1-dev.89711ab.0+89711ab", | ||
"web3-providers-ws": "4.0.8-dev.89711ab.0+89711ab", | ||
"web3-types": "1.7.1-dev.89711ab.0+89711ab", | ||
"web3-utils": "4.3.1-dev.89711ab.0+89711ab", | ||
"web3-validator": "2.0.7-dev.89711ab.0+89711ab" | ||
}, | ||
"gitHead": "1436228817c7e6362e7a82b8f79ec3b2e9c99412" | ||
"gitHead": "89711ab7f6a63d910848807ee77f0a91497aa897" | ||
} |
@@ -20,2 +20,3 @@ /* | ||
import WebSocketProvider from "web3-providers-ws"; | ||
import { isNullish } from "web3-validator"; | ||
import { | ||
@@ -27,6 +28,8 @@ EthExecutionAPI, JsonRpcResult, ProviderConnectInfo, ProviderMessage, | ||
Web3ProviderMessageEventCallback, | ||
Web3ProviderStatus | ||
Web3ProviderStatus, | ||
JsonRpcResponseWithResult, | ||
} from "web3-types"; | ||
import { Eip1193Provider } from "web3-utils"; | ||
import { Transport, Network } from "./types.js"; | ||
import { QuickNodeRateLimitError } from './errors.js'; | ||
@@ -73,9 +76,16 @@ /* | ||
requestOptions?: RequestInit, | ||
): Promise<ResultType> { | ||
): Promise<JsonRpcResponseWithResult<ResultType>> { | ||
if (this.transport === Transport.HTTPS) { | ||
return ( (this.provider as HttpProvider).request(payload, requestOptions)) as unknown as Promise<ResultType>; | ||
} | ||
const res = await ( (this.provider as HttpProvider).request(payload, requestOptions)) as unknown as JsonRpcResponseWithResult<ResultType>; | ||
if (typeof res === 'object' && !isNullish(res) && 'error' in res && !isNullish(res.error) && 'code' in res.error && (res.error as { code: number }).code === 429){ | ||
// rate limiting error by quicknode; | ||
throw new QuickNodeRateLimitError(); | ||
} | ||
return res; | ||
} | ||
return ( (this.provider as WebSocketProvider).request(payload)) as unknown as Promise<ResultType>; | ||
return (this.provider as WebSocketProvider).request(payload); | ||
@@ -82,0 +92,0 @@ } |
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
70928
45
937
6