From e58998023dffc38413b80602e2708a1c813028a5 Mon Sep 17 00:00:00 2001 From: Alex Luu Date: Thu, 13 Jun 2024 16:43:50 -0400 Subject: [PATCH 01/11] update http --- packages/web3-providers-http/src/index.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/web3-providers-http/src/index.ts b/packages/web3-providers-http/src/index.ts index 64dadd9895d..b6b9802a6bb 100644 --- a/packages/web3-providers-http/src/index.ts +++ b/packages/web3-providers-http/src/index.ts @@ -25,8 +25,9 @@ import { Web3APISpec, Web3BaseProvider, Web3ProviderStatus, + JsonRpcResponseWithError, } from 'web3-types'; -import { InvalidClientError, MethodNotImplementedError, ResponseError } from 'web3-errors'; +import { InvalidClientError, MethodNotImplementedError, ResponseError, LimitExceededError } from 'web3-errors'; import { HttpProviderOptions } from './types.js'; export { HttpProviderOptions } from './types.js'; @@ -78,9 +79,14 @@ export default class HttpProvider< }, body: JSON.stringify(payload), }); - - // eslint-disable-next-line @typescript-eslint/no-unsafe-argument - if (!response.ok) throw new ResponseError(await response.json()); + if (!response.ok) { + const errResponse = (response as unknown as JsonRpcResponseWithError); + if (errResponse.error.code === 429) { // too many requests + throw new LimitExceededError(errResponse); + } + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + throw new ResponseError(await response.json()) + }; return (await response.json()) as JsonRpcResponseWithResult; } From f694bf8d3f9c793e26616811feb83931e36288eb Mon Sep 17 00:00:00 2001 From: Alex Luu Date: Thu, 13 Jun 2024 23:32:24 -0400 Subject: [PATCH 02/11] update changelog --- packages/web3-providers-http/CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/web3-providers-http/CHANGELOG.md b/packages/web3-providers-http/CHANGELOG.md index 6d57af6dcf7..5c43bc33787 100644 --- a/packages/web3-providers-http/CHANGELOG.md +++ b/packages/web3-providers-http/CHANGELOG.md @@ -129,4 +129,6 @@ Documentation: - Fix issue lquixada/cross-fetch#78, enabling to run web3.js in service worker (#6463) -## [Unreleased] \ No newline at end of file +## [Unreleased] + +- returns LimitExceededError when code is 429 (#7102) \ No newline at end of file From e35181af4fa22d81cb8f79d7d7742695b94a3cc1 Mon Sep 17 00:00:00 2001 From: Alex Luu Date: Fri, 14 Jun 2024 09:43:01 -0400 Subject: [PATCH 03/11] update web3-rpc-providers --- packages/web3-errors/src/error_codes.ts | 3 +++ .../src/errors/quicknode_errors.ts | 27 +++++++++++++++++++ packages/web3-errors/src/index.ts | 1 + packages/web3-errors/test/unit/errors.test.ts | 2 ++ packages/web3-rpc-providers/package.json | 1 + .../web3-rpc-providers/src/web3_provider.ts | 12 ++++++++- 6 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 packages/web3-errors/src/errors/quicknode_errors.ts diff --git a/packages/web3-errors/src/error_codes.ts b/packages/web3-errors/src/error_codes.ts index 16c95ad81cb..14aca9ab914 100644 --- a/packages/web3-errors/src/error_codes.ts +++ b/packages/web3-errors/src/error_codes.ts @@ -168,6 +168,9 @@ export const ERR_CORE_CHAIN_MISMATCH = 1102; // Schema error codes export const ERR_SCHEMA_FORMAT = 1200; +export const ERR_QUICK_NODE_RATE_LIMIT = 1300; + + // RPC error codes (EIP-1474) // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1474.md export const ERR_RPC_INVALID_JSON = -32700; diff --git a/packages/web3-errors/src/errors/quicknode_errors.ts b/packages/web3-errors/src/errors/quicknode_errors.ts new file mode 100644 index 00000000000..a2cbdf9f969 --- /dev/null +++ b/packages/web3-errors/src/errors/quicknode_errors.ts @@ -0,0 +1,27 @@ +/* +This file is part of web3.js. + +web3.js is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +web3.js is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with web3.js. If not, see . +*/ + +import { BaseWeb3Error } from '../web3_error_base.js'; +import { ERR_QUICK_NODE_RATE_LIMIT } from '../error_codes.js'; + +export class QuickNodeRateLimitError extends BaseWeb3Error { + public code = ERR_QUICK_NODE_RATE_LIMIT; + + public constructor() { + super(`Too many requests, Quicknode has reached its rate limit.`); + } +} \ No newline at end of file diff --git a/packages/web3-errors/src/index.ts b/packages/web3-errors/src/index.ts index 2e4ef7abca6..5ca8dc4b6e9 100644 --- a/packages/web3-errors/src/index.ts +++ b/packages/web3-errors/src/index.ts @@ -22,6 +22,7 @@ export * from './errors/connection_errors.js'; export * from './errors/contract_errors.js'; export * from './errors/ens_errors.js'; export * from './errors/generic_errors.js'; +export * from './errors/quicknode_errors.js'; export * from './errors/provider_errors.js'; export * from './errors/signature_errors.js'; export * from './errors/transaction_errors.js'; diff --git a/packages/web3-errors/test/unit/errors.test.ts b/packages/web3-errors/test/unit/errors.test.ts index 7428cc9b6b3..511fb7d7286 100644 --- a/packages/web3-errors/test/unit/errors.test.ts +++ b/packages/web3-errors/test/unit/errors.test.ts @@ -27,6 +27,7 @@ import * as transactionErrors from '../../src/errors/transaction_errors'; import * as utilsErrors from '../../src/errors/utils_errors'; import * as responseErrors from '../../src/errors/response_errors'; import * as schemaErrors from '../../src/errors/schema_errors'; +import * as quickNodeErrors from '../../src/errors/quicknode_errors'; import { ConvertValueToString } from '../fixtures/errors'; import { BaseWeb3Error } from '../../src/web3_error_base'; @@ -52,6 +53,7 @@ describe('errors', () => { ...transactionErrors, ...utilsErrors, ...schemaErrors, + ...quickNodeErrors })) { if (ErrorClass === transactionErrors.InvalidPropertiesForTransactionTypeError) break; // To disable error for the abstract class diff --git a/packages/web3-rpc-providers/package.json b/packages/web3-rpc-providers/package.json index a3046999279..d1bc7c6b93c 100644 --- a/packages/web3-rpc-providers/package.json +++ b/packages/web3-rpc-providers/package.json @@ -56,6 +56,7 @@ "typescript": "^4.7.4" }, "dependencies": { + "web3-errors": "^1.2.0", "web3-providers-http": "^4.1.0", "web3-providers-ws": "^4.0.7", "web3-types": "^1.6.0", diff --git a/packages/web3-rpc-providers/src/web3_provider.ts b/packages/web3-rpc-providers/src/web3_provider.ts index 2bba9a7b880..30cd36406c4 100644 --- a/packages/web3-rpc-providers/src/web3_provider.ts +++ b/packages/web3-rpc-providers/src/web3_provider.ts @@ -25,6 +25,7 @@ import { Web3ProviderMessageEventCallback, Web3ProviderStatus } from "web3-types"; +import { QuickNodeRateLimitError } from "web3-errors"; import { Eip1193Provider } from "web3-utils"; import { Transport, Network } from "./types.js"; @@ -71,9 +72,18 @@ API extends Web3APISpec = EthExecutionAPI, ): Promise { if (this.transport === Transport.HTTPS) { - return ( (this.provider as HttpProvider).request(payload, requestOptions)) as unknown as Promise; + try { + return ( (this.provider as HttpProvider).request(payload, requestOptions)) as unknown as Promise; + } catch(e) { + if (e.code && e.code === 429){ + // rate limiting error by quicknode; + throw new QuickNodeRateLimitError(); + + } + } } + return ( (this.provider as WebSocketProvider).request(payload)) as unknown as Promise; } From 399355181941e1b57b6fbc0daa5124e2d4e1f0c3 Mon Sep 17 00:00:00 2001 From: Alex Luu Date: Fri, 14 Jun 2024 10:17:53 -0400 Subject: [PATCH 04/11] update --- packages/web3-providers-http/CHANGELOG.md | 4 +--- packages/web3-providers-http/src/index.ts | 7 +------ packages/web3-rpc-providers/CHANGELOG.md | 1 + 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/packages/web3-providers-http/CHANGELOG.md b/packages/web3-providers-http/CHANGELOG.md index 5c43bc33787..6d57af6dcf7 100644 --- a/packages/web3-providers-http/CHANGELOG.md +++ b/packages/web3-providers-http/CHANGELOG.md @@ -129,6 +129,4 @@ Documentation: - Fix issue lquixada/cross-fetch#78, enabling to run web3.js in service worker (#6463) -## [Unreleased] - -- returns LimitExceededError when code is 429 (#7102) \ No newline at end of file +## [Unreleased] \ No newline at end of file diff --git a/packages/web3-providers-http/src/index.ts b/packages/web3-providers-http/src/index.ts index b6b9802a6bb..bd069dbc14c 100644 --- a/packages/web3-providers-http/src/index.ts +++ b/packages/web3-providers-http/src/index.ts @@ -25,9 +25,8 @@ import { Web3APISpec, Web3BaseProvider, Web3ProviderStatus, - JsonRpcResponseWithError, } from 'web3-types'; -import { InvalidClientError, MethodNotImplementedError, ResponseError, LimitExceededError } from 'web3-errors'; +import { InvalidClientError, MethodNotImplementedError, ResponseError } from 'web3-errors'; import { HttpProviderOptions } from './types.js'; export { HttpProviderOptions } from './types.js'; @@ -80,10 +79,6 @@ export default class HttpProvider< body: JSON.stringify(payload), }); if (!response.ok) { - const errResponse = (response as unknown as JsonRpcResponseWithError); - if (errResponse.error.code === 429) { // too many requests - throw new LimitExceededError(errResponse); - } // eslint-disable-next-line @typescript-eslint/no-unsafe-argument throw new ResponseError(await response.json()) }; diff --git a/packages/web3-rpc-providers/CHANGELOG.md b/packages/web3-rpc-providers/CHANGELOG.md index 87f56484e8e..32fb5da2297 100644 --- a/packages/web3-rpc-providers/CHANGELOG.md +++ b/packages/web3-rpc-providers/CHANGELOG.md @@ -36,3 +36,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 --> ## [Unreleased] + - When error is returned with code 429, throw rate limit error (#7102) \ No newline at end of file From d64432e246b41c33c16f534b4a0030bde440f3de Mon Sep 17 00:00:00 2001 From: Alex Luu Date: Fri, 14 Jun 2024 10:24:33 -0400 Subject: [PATCH 05/11] update --- packages/web3-rpc-providers/src/web3_provider.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/web3-rpc-providers/src/web3_provider.ts b/packages/web3-rpc-providers/src/web3_provider.ts index 30cd36406c4..f602ff0d7c1 100644 --- a/packages/web3-rpc-providers/src/web3_provider.ts +++ b/packages/web3-rpc-providers/src/web3_provider.ts @@ -74,8 +74,9 @@ API extends Web3APISpec = EthExecutionAPI, if (this.transport === Transport.HTTPS) { try { return ( (this.provider as HttpProvider).request(payload, requestOptions)) as unknown as Promise; - } catch(e) { - if (e.code && e.code === 429){ + } catch(e: unknown) { + // eslint-disable-next-line no-null/no-null + if (typeof e === 'object' && e !== null && 'code' in e && (e as { code: number }).code === 429){ // rate limiting error by quicknode; throw new QuickNodeRateLimitError(); From e269e1fdebae6578141b24cbb1fc3fe9c56e74f9 Mon Sep 17 00:00:00 2001 From: Alex Luu Date: Fri, 14 Jun 2024 10:30:09 -0400 Subject: [PATCH 06/11] update --- packages/web3-rpc-providers/package.json | 3 ++- packages/web3-rpc-providers/src/web3_provider.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/web3-rpc-providers/package.json b/packages/web3-rpc-providers/package.json index d1bc7c6b93c..2008c43d599 100644 --- a/packages/web3-rpc-providers/package.json +++ b/packages/web3-rpc-providers/package.json @@ -60,6 +60,7 @@ "web3-providers-http": "^4.1.0", "web3-providers-ws": "^4.0.7", "web3-types": "^1.6.0", - "web3-utils": "^4.2.3" + "web3-utils": "^4.2.3", + "web3-validator": "^2.0.6" } } diff --git a/packages/web3-rpc-providers/src/web3_provider.ts b/packages/web3-rpc-providers/src/web3_provider.ts index f602ff0d7c1..12591785458 100644 --- a/packages/web3-rpc-providers/src/web3_provider.ts +++ b/packages/web3-rpc-providers/src/web3_provider.ts @@ -17,6 +17,7 @@ along with web3.js. If not, see . import HttpProvider from "web3-providers-http"; import WebSocketProvider from "web3-providers-ws"; +import { isNullish } from "web3-validator"; import { EthExecutionAPI, JsonRpcResult, ProviderConnectInfo, ProviderMessage, ProviderRpcError, Web3APIMethod, Web3APIPayload, Web3APIReturnType, Web3APISpec, Web3BaseProvider, @@ -75,8 +76,7 @@ API extends Web3APISpec = EthExecutionAPI, try { return ( (this.provider as HttpProvider).request(payload, requestOptions)) as unknown as Promise; } catch(e: unknown) { - // eslint-disable-next-line no-null/no-null - if (typeof e === 'object' && e !== null && 'code' in e && (e as { code: number }).code === 429){ + if (typeof e === 'object' && !isNullish(e) && 'code' in e && (e as { code: number }).code === 429){ // rate limiting error by quicknode; throw new QuickNodeRateLimitError(); From 6134ceb6e29f6bd5bbe054648e45fd5c1be8c560 Mon Sep 17 00:00:00 2001 From: Alex Luu Date: Wed, 19 Jun 2024 14:58:54 -0400 Subject: [PATCH 07/11] update tests --- packages/web3-rpc-providers/src/errors.ts | 28 ++++++++++++++++++ .../web3-rpc-providers/src/web3_provider.ts | 17 +++++------ .../test/unit/request.test.ts | 29 +++++++++++++++++++ 3 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 packages/web3-rpc-providers/src/errors.ts diff --git a/packages/web3-rpc-providers/src/errors.ts b/packages/web3-rpc-providers/src/errors.ts new file mode 100644 index 00000000000..dd602fcb05f --- /dev/null +++ b/packages/web3-rpc-providers/src/errors.ts @@ -0,0 +1,28 @@ +/* +This file is part of web3.js. + +web3.js is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +web3.js is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with web3.js. If not, see . +*/ + +import { BaseWeb3Error } from 'web3-errors'; +import { } from 'web3-types'; + +const ERR_QUICK_NODE_RATE_LIMIT = 1300; +export class QuickNodeRateLimitError extends BaseWeb3Error { + public code = ERR_QUICK_NODE_RATE_LIMIT; + + public constructor() { + super(`Too many requests, Quicknode has reached its rate limit.`); + } +} \ No newline at end of file diff --git a/packages/web3-rpc-providers/src/web3_provider.ts b/packages/web3-rpc-providers/src/web3_provider.ts index 12591785458..5a856317af5 100644 --- a/packages/web3-rpc-providers/src/web3_provider.ts +++ b/packages/web3-rpc-providers/src/web3_provider.ts @@ -24,11 +24,12 @@ import { Web3Eip1193ProviderEventCallback, Web3ProviderEventCallback, Web3ProviderMessageEventCallback, - Web3ProviderStatus + Web3ProviderStatus, + JsonRpcResponseWithResult, } from "web3-types"; -import { QuickNodeRateLimitError } from "web3-errors"; import { Eip1193Provider } from "web3-utils"; import { Transport, Network } from "./types.js"; +import { QuickNodeRateLimitError } from './errors.js'; /* This class can be used to create new providers only when there is custom logic required in each Request method like @@ -73,19 +74,17 @@ API extends Web3APISpec = EthExecutionAPI, ): Promise { if (this.transport === Transport.HTTPS) { - try { - return ( (this.provider as HttpProvider).request(payload, requestOptions)) as unknown as Promise; - } catch(e: unknown) { - if (typeof e === 'object' && !isNullish(e) && 'code' in e && (e as { code: number }).code === 429){ + const res = await ( (this.provider as HttpProvider).request(payload, requestOptions)) as unknown as JsonRpcResponseWithResult; + + 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 as unknown as Promise; } - } - - return ( (this.provider as WebSocketProvider).request(payload)) as unknown as Promise; + return (this.provider as WebSocketProvider).request(payload) as unknown as Promise; } diff --git a/packages/web3-rpc-providers/test/unit/request.test.ts b/packages/web3-rpc-providers/test/unit/request.test.ts index ccbaa0f7cc7..d0d38ac5e14 100644 --- a/packages/web3-rpc-providers/test/unit/request.test.ts +++ b/packages/web3-rpc-providers/test/unit/request.test.ts @@ -17,6 +17,7 @@ along with web3.js. If not, see . import { Web3APIPayload, EthExecutionAPI, Web3APIMethod } from "web3-types"; import { Network, Transport } from "../../src/types"; import { Web3ExternalProvider } from "../../src/web3_provider"; +import { QuickNodeRateLimitError } from '../../src/errors'; jest.mock('web3-providers-ws', () => { return { @@ -78,4 +79,32 @@ describe('Web3ExternalProvider', () => { const result = await provider.request(payload); expect(result).toEqual({ result: 'mock-result' }); }); + it('should return a rate limiting error when code is 429', async () => { + const network: Network = Network.ETH_MAINNET; + const transport: Transport = Transport.HTTPS; + const token = 'your-token'; + + const mockHttpProvider = { + request: jest.fn(), + }; + + const mockResponse = { + jsonrpc: '2.0', + id: '458408f4-7e2c-43f1-b61d-1fe09a9ee25a', + error: { + code: 429, + message: 'the method eth_stuff does not exist/is not available' + } + }; + mockHttpProvider.request.mockResolvedValue(mockResponse); + + const provider = new MockWeb3ExternalProvider(network, transport, token); + (provider as any).provider = mockHttpProvider; + + const payload: Web3APIPayload> = { + method: 'eth_getBalance', + params: ['0x0123456789012345678901234567890123456789', 'latest'], + }; + await expect(provider.request(payload)).rejects.toThrow(QuickNodeRateLimitError); + }); }); \ No newline at end of file From 499374e4aef25f708f3200a0740c08b45f05c7e5 Mon Sep 17 00:00:00 2001 From: Alex Luu Date: Wed, 19 Jun 2024 15:27:38 -0400 Subject: [PATCH 08/11] remove quicknode errors --- packages/web3-errors/src/error_codes.ts | 3 --- .../src/errors/quicknode_errors.ts | 27 ------------------- packages/web3-errors/src/index.ts | 1 - packages/web3-errors/test/unit/errors.test.ts | 1 - 4 files changed, 32 deletions(-) delete mode 100644 packages/web3-errors/src/errors/quicknode_errors.ts diff --git a/packages/web3-errors/src/error_codes.ts b/packages/web3-errors/src/error_codes.ts index 14aca9ab914..16c95ad81cb 100644 --- a/packages/web3-errors/src/error_codes.ts +++ b/packages/web3-errors/src/error_codes.ts @@ -168,9 +168,6 @@ export const ERR_CORE_CHAIN_MISMATCH = 1102; // Schema error codes export const ERR_SCHEMA_FORMAT = 1200; -export const ERR_QUICK_NODE_RATE_LIMIT = 1300; - - // RPC error codes (EIP-1474) // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1474.md export const ERR_RPC_INVALID_JSON = -32700; diff --git a/packages/web3-errors/src/errors/quicknode_errors.ts b/packages/web3-errors/src/errors/quicknode_errors.ts deleted file mode 100644 index a2cbdf9f969..00000000000 --- a/packages/web3-errors/src/errors/quicknode_errors.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* -This file is part of web3.js. - -web3.js is free software: you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -web3.js is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with web3.js. If not, see . -*/ - -import { BaseWeb3Error } from '../web3_error_base.js'; -import { ERR_QUICK_NODE_RATE_LIMIT } from '../error_codes.js'; - -export class QuickNodeRateLimitError extends BaseWeb3Error { - public code = ERR_QUICK_NODE_RATE_LIMIT; - - public constructor() { - super(`Too many requests, Quicknode has reached its rate limit.`); - } -} \ No newline at end of file diff --git a/packages/web3-errors/src/index.ts b/packages/web3-errors/src/index.ts index 5ca8dc4b6e9..2e4ef7abca6 100644 --- a/packages/web3-errors/src/index.ts +++ b/packages/web3-errors/src/index.ts @@ -22,7 +22,6 @@ export * from './errors/connection_errors.js'; export * from './errors/contract_errors.js'; export * from './errors/ens_errors.js'; export * from './errors/generic_errors.js'; -export * from './errors/quicknode_errors.js'; export * from './errors/provider_errors.js'; export * from './errors/signature_errors.js'; export * from './errors/transaction_errors.js'; diff --git a/packages/web3-errors/test/unit/errors.test.ts b/packages/web3-errors/test/unit/errors.test.ts index 511fb7d7286..99bac06c357 100644 --- a/packages/web3-errors/test/unit/errors.test.ts +++ b/packages/web3-errors/test/unit/errors.test.ts @@ -53,7 +53,6 @@ describe('errors', () => { ...transactionErrors, ...utilsErrors, ...schemaErrors, - ...quickNodeErrors })) { if (ErrorClass === transactionErrors.InvalidPropertiesForTransactionTypeError) break; // To disable error for the abstract class From 63e5bd74490522d7301277b484b0e02f54aeb905 Mon Sep 17 00:00:00 2001 From: Alex Luu Date: Wed, 19 Jun 2024 16:03:25 -0400 Subject: [PATCH 09/11] update imports --- packages/web3-errors/test/unit/errors.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/web3-errors/test/unit/errors.test.ts b/packages/web3-errors/test/unit/errors.test.ts index 99bac06c357..7428cc9b6b3 100644 --- a/packages/web3-errors/test/unit/errors.test.ts +++ b/packages/web3-errors/test/unit/errors.test.ts @@ -27,7 +27,6 @@ import * as transactionErrors from '../../src/errors/transaction_errors'; import * as utilsErrors from '../../src/errors/utils_errors'; import * as responseErrors from '../../src/errors/response_errors'; import * as schemaErrors from '../../src/errors/schema_errors'; -import * as quickNodeErrors from '../../src/errors/quicknode_errors'; import { ConvertValueToString } from '../fixtures/errors'; import { BaseWeb3Error } from '../../src/web3_error_base'; From 823e347ba05d6ae8c4c9039bd13ca341b41f22e9 Mon Sep 17 00:00:00 2001 From: Alex Luu Date: Thu, 20 Jun 2024 13:54:26 -0400 Subject: [PATCH 10/11] change return type of request --- packages/web3-rpc-providers/src/web3_provider.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/web3-rpc-providers/src/web3_provider.ts b/packages/web3-rpc-providers/src/web3_provider.ts index 5a856317af5..a00034048ef 100644 --- a/packages/web3-rpc-providers/src/web3_provider.ts +++ b/packages/web3-rpc-providers/src/web3_provider.ts @@ -71,7 +71,7 @@ API extends Web3APISpec = EthExecutionAPI, >( payload: Web3APIPayload, requestOptions?: RequestInit, - ): Promise { + ): Promise> { if (this.transport === Transport.HTTPS) { const res = await ( (this.provider as HttpProvider).request(payload, requestOptions)) as unknown as JsonRpcResponseWithResult; @@ -81,10 +81,10 @@ API extends Web3APISpec = EthExecutionAPI, throw new QuickNodeRateLimitError(); } - return res as unknown as Promise; + return res; } - return (this.provider as WebSocketProvider).request(payload) as unknown as Promise; + return (this.provider as WebSocketProvider).request(payload); } From 3918535a0841a00e1ccca028244d66b18e71dac8 Mon Sep 17 00:00:00 2001 From: Alex Luu Date: Thu, 20 Jun 2024 15:32:31 -0400 Subject: [PATCH 11/11] update changelog --- packages/web3-rpc-providers/CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/web3-rpc-providers/CHANGELOG.md b/packages/web3-rpc-providers/CHANGELOG.md index d51832b4255..78d7c02f440 100644 --- a/packages/web3-rpc-providers/CHANGELOG.md +++ b/packages/web3-rpc-providers/CHANGELOG.md @@ -42,4 +42,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - RC release ## [Unreleased] - - When error is returned with code 429, throw rate limit error (#7102) \ No newline at end of file + - When error is returned with code 429, throw rate limit error (#7102) + - Change request return type `Promise` to `Promise>` (#7102) \ No newline at end of file