From cd25b34164463378572d36d5b7e610ef6ce62e46 Mon Sep 17 00:00:00 2001 From: Mario Rivera Date: Wed, 2 Oct 2024 14:20:49 -0400 Subject: [PATCH 01/10] Add alchemy rpc provider --- packages/web3-rpc-providers/src/index.ts | 3 + .../src/web3_provider_alchemy.ts | 124 ++++++++++++++++++ 2 files changed, 127 insertions(+) create mode 100644 packages/web3-rpc-providers/src/web3_provider_alchemy.ts diff --git a/packages/web3-rpc-providers/src/index.ts b/packages/web3-rpc-providers/src/index.ts index 577d8e6b960..d486ba26477 100644 --- a/packages/web3-rpc-providers/src/index.ts +++ b/packages/web3-rpc-providers/src/index.ts @@ -16,11 +16,14 @@ along with web3.js. If not, see . */ import { QuickNodeProvider } from './web3_provider_quicknode.js'; +import { AlchemyProvider } from './web3_provider_alchemy.js'; export * from './types.js'; export * from './web3_provider_quicknode.js'; export * from './web3_provider.js'; export * from './errors.js'; +export * from './web3_provider_alchemy.js'; // default providers export const mainnet = new QuickNodeProvider(); +export const alchemy = new AlchemyProvider(); diff --git a/packages/web3-rpc-providers/src/web3_provider_alchemy.ts b/packages/web3-rpc-providers/src/web3_provider_alchemy.ts new file mode 100644 index 00000000000..613bb8394ec --- /dev/null +++ b/packages/web3-rpc-providers/src/web3_provider_alchemy.ts @@ -0,0 +1,124 @@ +/* +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 { + EthExecutionAPI, + Web3APIMethod, + Web3APIPayload, + Web3APIReturnType, + JsonRpcResponseWithResult, + Web3APISpec, +} from 'web3-types'; +import { HttpProviderOptions } from 'web3-providers-http'; +import { ResponseError } from 'web3-errors'; +import { Web3ExternalProvider } from './web3_provider.js'; +import { Network, Transport, SocketOptions } from './types.js'; + +function isValid(value: string): boolean { + return !!(value && value.trim().length > 0); +} + +export class AlchemyProvider< + API extends Web3APISpec = EthExecutionAPI, +> extends Web3ExternalProvider { + public constructor( + network: Network = Network.ETH_MAINNET, + transport: Transport = Transport.HTTPS, + token = '', + host = '', + providerConfigOptions?: HttpProviderOptions | SocketOptions, + ) { + super(network, transport, token, host, providerConfigOptions); + } + + public async request< + Method extends Web3APIMethod, + ResultType = Web3APIReturnType, + >( + payload: Web3APIPayload, + requestOptions?: RequestInit, + ): Promise> { + try { + return await super.request(payload, requestOptions); + } catch (error) { + if (error instanceof ResponseError && error.statusCode === 429) { + throw new Error('Alchemy rate limit exceeded'); + } + throw error; + } + } + + // 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 : 'eth-mainnet.g.alchemy.com'; + token = isValid(_token) ? _token : 'alchemy-mainnet-token'; + break; + case Network.ETH_SEPOLIA: + host = isValid(_host) ? _host : 'eth-sepolia.g.alchemy.com'; + token = isValid(_token) ? _token : 'alchemy-sepolia-token'; + break; + case Network.ETH_GOERLI: + host = isValid(_host) ? _host : 'eth-goerli.g.alchemy.com'; + token = isValid(_token) ? _token : 'alchemy-goerli-token'; + break; + + case Network.ARBITRUM_MAINNET: + host = isValid(_host) ? _host : 'arb-mainnet.g.alchemy.com'; + token = isValid(_token) ? _token : 'alchemy-arbitrum-mainnet-token'; + break; + case Network.ARBITRUM_SEPOLIA: + host = isValid(_host) ? _host : 'arb-sepolia.g.alchemy.com'; + token = isValid(_token) ? _token : 'alchemy-arbitrum-sepolia-token'; + break; + + case Network.BASE_MAINNET: + host = isValid(_host) ? _host : 'base-mainnet.g.alchemy.com'; + token = isValid(_token) ? _token : 'alchemy-base-mainnet-token'; + break; + case Network.BASE_SEPOLIA: + host = isValid(_host) ? _host : 'base-sepolia.g.alchemy.com'; + token = isValid(_token) ? _token : 'alchemy-base-sepolia-token'; + break; + + case Network.POLYGON_MAINNET: + host = isValid(_host) ? _host : 'polygon-mainnet.g.alchemy.com'; + token = isValid(_token) ? _token : 'alchemy-polygon-mainnet-token'; + break; + case Network.POLYGON_AMOY: + host = isValid(_host) ? _host : 'polygon-amoy.g.alchemy.com'; + token = isValid(_token) ? _token : 'alchemy-polygon-amoy-token'; + break; + + case Network.OPTIMISM_MAINNET: + host = isValid(_host) ? _host : 'opt-mainnet.g.alchemy.com'; + token = isValid(_token) ? _token : 'alchemy-optimism-mainnet-token'; + break; + case Network.OPTIMISM_SEPOLIA: + host = isValid(_host) ? _host : 'opt-sepolia.g.alchemy.com'; + token = isValid(_token) ? _token : 'alchemy-optimism-sepolia-token'; + break; + default: + throw new Error('Network info not available.'); + } + + return `${transport}://${host}/v2/${token}`; + } +} From 66d3592d9ad798c6bbdd5a6468da2f647fcf10c6 Mon Sep 17 00:00:00 2001 From: Mario Rivera Date: Wed, 2 Oct 2024 14:22:02 -0400 Subject: [PATCH 02/10] Add Polygon AMOY network (replaces MUMBAI) --- packages/web3-rpc-providers/src/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web3-rpc-providers/src/types.ts b/packages/web3-rpc-providers/src/types.ts index 9fda306ae0d..00348eeba80 100644 --- a/packages/web3-rpc-providers/src/types.ts +++ b/packages/web3-rpc-providers/src/types.ts @@ -30,8 +30,8 @@ export enum Network { ETH_HOLESKY = 'eth_holesky', POLYGON_MAINNET = 'polygon_mainnet', - POLYGON_MUMBAI = 'polygon_mumbai', POLYGON_AMONY = 'polygon_amony', + POLYGON_AMOY = 'polygon_amoy', ARBITRUM_MAINNET = 'arbitrum_mainnet', ARBITRUM_SEPOLIA = 'arbitrum_sepolia', From 40af4b778617a01eb7b8870259186361c446bf91 Mon Sep 17 00:00:00 2001 From: Mario Rivera Date: Wed, 2 Oct 2024 14:26:41 -0400 Subject: [PATCH 03/10] Keep this for now, check what is using this property --- packages/web3-rpc-providers/src/types.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/web3-rpc-providers/src/types.ts b/packages/web3-rpc-providers/src/types.ts index 00348eeba80..366f4c35583 100644 --- a/packages/web3-rpc-providers/src/types.ts +++ b/packages/web3-rpc-providers/src/types.ts @@ -30,6 +30,7 @@ export enum Network { ETH_HOLESKY = 'eth_holesky', POLYGON_MAINNET = 'polygon_mainnet', + POLYGON_MUMBAI = 'polygon_mumbai', POLYGON_AMONY = 'polygon_amony', POLYGON_AMOY = 'polygon_amoy', From 9ec6145c4051fa066fdbcf7156e3843a18a66ecd Mon Sep 17 00:00:00 2001 From: Mario Rivera Date: Wed, 2 Oct 2024 14:26:54 -0400 Subject: [PATCH 04/10] Testing --- .../web3/test/integration/web3RPCProviders.test.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/web3/test/integration/web3RPCProviders.test.ts b/packages/web3/test/integration/web3RPCProviders.test.ts index 1faeffad452..6dd7d631b59 100644 --- a/packages/web3/test/integration/web3RPCProviders.test.ts +++ b/packages/web3/test/integration/web3RPCProviders.test.ts @@ -16,6 +16,7 @@ along with web3.js. If not, see . */ import { mainnet, Network, QuickNodeProvider, Transport } from 'web3-rpc-providers'; +import { AlchemyProvider } from 'web3-rpc-providers/src'; import { Web3 } from '../../src/index'; describe('Web3 RPC Provider Integration tests', () => { @@ -42,6 +43,18 @@ describe('Web3 RPC Provider Integration tests', () => { expect(typeof result).toBe('bigint'); expect(result > 0).toBe(true); + if (transport === Transport.WebSocket) { + web3.provider?.disconnect(); + } + }); + it(`AlchemyProvider should work with ${transport} transport and ${network} network`, async () => { + const provider = new AlchemyProvider(network, transport); + const web3 = new Web3(provider); + const result = await web3.eth.getBlockNumber(); + + expect(typeof result).toBe('bigint'); + expect(result > 0).toBe(true); + if (transport === Transport.WebSocket) { web3.provider?.disconnect(); } From ba693ba1f0c46285cc1ae0a0457a15dc477eb356 Mon Sep 17 00:00:00 2001 From: Mario Rivera <150161290+MRLab12@users.noreply.github.com> Date: Mon, 7 Oct 2024 11:42:48 -0400 Subject: [PATCH 05/10] Remove request method Co-authored-by: Junaid <86780488+jdevcs@users.noreply.github.com> --- .../src/web3_provider_alchemy.ts | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/packages/web3-rpc-providers/src/web3_provider_alchemy.ts b/packages/web3-rpc-providers/src/web3_provider_alchemy.ts index 613bb8394ec..7b92d8ab105 100644 --- a/packages/web3-rpc-providers/src/web3_provider_alchemy.ts +++ b/packages/web3-rpc-providers/src/web3_provider_alchemy.ts @@ -44,22 +44,6 @@ export class AlchemyProvider< super(network, transport, token, host, providerConfigOptions); } - public async request< - Method extends Web3APIMethod, - ResultType = Web3APIReturnType, - >( - payload: Web3APIPayload, - requestOptions?: RequestInit, - ): Promise> { - try { - return await super.request(payload, requestOptions); - } catch (error) { - if (error instanceof ResponseError && error.statusCode === 429) { - throw new Error('Alchemy rate limit exceeded'); - } - throw error; - } - } // eslint-disable-next-line class-methods-use-this public getRPCURL(network: Network, transport: Transport, _token: string, _host: string) { From bed9651539fad2799844d5a62f129dfe54ef4713 Mon Sep 17 00:00:00 2001 From: Mario Rivera Date: Mon, 7 Oct 2024 13:31:10 -0400 Subject: [PATCH 06/10] Updating imports and unused API extension / Use map instead of switch --- .../src/web3_provider_alchemy.ts | 83 ++++--------------- 1 file changed, 18 insertions(+), 65 deletions(-) diff --git a/packages/web3-rpc-providers/src/web3_provider_alchemy.ts b/packages/web3-rpc-providers/src/web3_provider_alchemy.ts index 7b92d8ab105..bf97c5fe5eb 100644 --- a/packages/web3-rpc-providers/src/web3_provider_alchemy.ts +++ b/packages/web3-rpc-providers/src/web3_provider_alchemy.ts @@ -14,16 +14,7 @@ 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 { - EthExecutionAPI, - Web3APIMethod, - Web3APIPayload, - Web3APIReturnType, - JsonRpcResponseWithResult, - Web3APISpec, -} from 'web3-types'; import { HttpProviderOptions } from 'web3-providers-http'; -import { ResponseError } from 'web3-errors'; import { Web3ExternalProvider } from './web3_provider.js'; import { Network, Transport, SocketOptions } from './types.js'; @@ -31,9 +22,7 @@ function isValid(value: string): boolean { return !!(value && value.trim().length > 0); } -export class AlchemyProvider< - API extends Web3APISpec = EthExecutionAPI, -> extends Web3ExternalProvider { +export class AlchemyProvider extends Web3ExternalProvider { public constructor( network: Network = Network.ETH_MAINNET, transport: Transport = Transport.HTTPS, @@ -44,63 +33,27 @@ export class AlchemyProvider< super(network, transport, token, host, providerConfigOptions); } + public static readonly networkStringMap: { [key: string]: string } = { + [Network.ETH_MAINNET]: 'eth-mainnet.g.alchemy.com', + [Network.ETH_SEPOLIA]: 'eth-sepolia.g.alchemy.com', + [Network.ETH_GOERLI]: 'eth-goerli.g.alchemy.com', + [Network.ARBITRUM_MAINNET]: 'arb-mainnet.g.alchemy.com', + [Network.ARBITRUM_SEPOLIA]: 'arb-sepolia.g.alchemy.com', + [Network.BASE_MAINNET]: 'base-mainnet.g.alchemy.com', + [Network.BASE_SEPOLIA]: 'base-sepolia.g.alchemy.com', + [Network.POLYGON_MAINNET]: 'polygon-mainnet.g.alchemy.com', + [Network.POLYGON_AMOY]: 'polygon-amoy.g.alchemy.com', + [Network.OPTIMISM_MAINNET]: 'opt-mainnet.g.alchemy.com', + [Network.OPTIMISM_SEPOLIA]: 'opt-sepolia.g.alchemy.com', + }; // eslint-disable-next-line class-methods-use-this public getRPCURL(network: Network, transport: Transport, _token: string, _host: string) { - let host = ''; - let token = ''; + const host = AlchemyProvider.networkStringMap[network] || ''; + const token = isValid(_token) ? _token : `alchemy-${network.toLowerCase()}-token`; - switch (network) { - case Network.ETH_MAINNET: - host = isValid(_host) ? _host : 'eth-mainnet.g.alchemy.com'; - token = isValid(_token) ? _token : 'alchemy-mainnet-token'; - break; - case Network.ETH_SEPOLIA: - host = isValid(_host) ? _host : 'eth-sepolia.g.alchemy.com'; - token = isValid(_token) ? _token : 'alchemy-sepolia-token'; - break; - case Network.ETH_GOERLI: - host = isValid(_host) ? _host : 'eth-goerli.g.alchemy.com'; - token = isValid(_token) ? _token : 'alchemy-goerli-token'; - break; - - case Network.ARBITRUM_MAINNET: - host = isValid(_host) ? _host : 'arb-mainnet.g.alchemy.com'; - token = isValid(_token) ? _token : 'alchemy-arbitrum-mainnet-token'; - break; - case Network.ARBITRUM_SEPOLIA: - host = isValid(_host) ? _host : 'arb-sepolia.g.alchemy.com'; - token = isValid(_token) ? _token : 'alchemy-arbitrum-sepolia-token'; - break; - - case Network.BASE_MAINNET: - host = isValid(_host) ? _host : 'base-mainnet.g.alchemy.com'; - token = isValid(_token) ? _token : 'alchemy-base-mainnet-token'; - break; - case Network.BASE_SEPOLIA: - host = isValid(_host) ? _host : 'base-sepolia.g.alchemy.com'; - token = isValid(_token) ? _token : 'alchemy-base-sepolia-token'; - break; - - case Network.POLYGON_MAINNET: - host = isValid(_host) ? _host : 'polygon-mainnet.g.alchemy.com'; - token = isValid(_token) ? _token : 'alchemy-polygon-mainnet-token'; - break; - case Network.POLYGON_AMOY: - host = isValid(_host) ? _host : 'polygon-amoy.g.alchemy.com'; - token = isValid(_token) ? _token : 'alchemy-polygon-amoy-token'; - break; - - case Network.OPTIMISM_MAINNET: - host = isValid(_host) ? _host : 'opt-mainnet.g.alchemy.com'; - token = isValid(_token) ? _token : 'alchemy-optimism-mainnet-token'; - break; - case Network.OPTIMISM_SEPOLIA: - host = isValid(_host) ? _host : 'opt-sepolia.g.alchemy.com'; - token = isValid(_token) ? _token : 'alchemy-optimism-sepolia-token'; - break; - default: - throw new Error('Network info not available.'); + if (!host) { + throw new Error('Network info not available.'); } return `${transport}://${host}/v2/${token}`; From f3b4df76ed14d5623973983ffa3166ecf57a0fbe Mon Sep 17 00:00:00 2001 From: Mario Rivera Date: Tue, 8 Oct 2024 18:53:44 -0400 Subject: [PATCH 07/10] Fix import in rpc tests --- packages/web3/test/integration/web3RPCProviders.test.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/web3/test/integration/web3RPCProviders.test.ts b/packages/web3/test/integration/web3RPCProviders.test.ts index 6dd7d631b59..1bf6300f5d8 100644 --- a/packages/web3/test/integration/web3RPCProviders.test.ts +++ b/packages/web3/test/integration/web3RPCProviders.test.ts @@ -15,8 +15,13 @@ You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ -import { mainnet, Network, QuickNodeProvider, Transport } from 'web3-rpc-providers'; -import { AlchemyProvider } from 'web3-rpc-providers/src'; +import { + mainnet, + Network, + QuickNodeProvider, + Transport, + AlchemyProvider, +} from 'web3-rpc-providers'; import { Web3 } from '../../src/index'; describe('Web3 RPC Provider Integration tests', () => { From 2f514c009e11b8554def5ca803bcdeb181878854 Mon Sep 17 00:00:00 2001 From: Mario Rivera Date: Mon, 21 Oct 2024 20:33:54 -0400 Subject: [PATCH 08/10] Include more Alchemy networks --- packages/web3-rpc-providers/src/types.ts | 67 +++++++++++++++++++ .../src/web3_provider_alchemy.ts | 47 +++++++++++++ 2 files changed, 114 insertions(+) diff --git a/packages/web3-rpc-providers/src/types.ts b/packages/web3-rpc-providers/src/types.ts index 366f4c35583..1f92c23bc84 100644 --- a/packages/web3-rpc-providers/src/types.ts +++ b/packages/web3-rpc-providers/src/types.ts @@ -33,9 +33,13 @@ export enum Network { POLYGON_MUMBAI = 'polygon_mumbai', POLYGON_AMONY = 'polygon_amony', POLYGON_AMOY = 'polygon_amoy', + POLYGON_POS_MAINNET = 'polygon_pos_mainnet', + POLYGON_ZKEVM_MAINNET = 'polygon_zkevm_mainnet', + POLYGON_ZKEVM_CARDONA = 'polygon_zkevm_cardona', ARBITRUM_MAINNET = 'arbitrum_mainnet', ARBITRUM_SEPOLIA = 'arbitrum_sepolia', + ARBITRUM_NOVA_MAINNET = 'arbitrum_nova_mainnet', BASE_MAINNET = 'base_mainnet', BASE_SEPOLIA = 'base_sepolia', @@ -45,6 +49,69 @@ export enum Network { BNB_MAINNET = 'bnb_mainnet', BNB_TESTNET = 'bnb_testnet', + + WORLD_CHAIN_MAINNET = 'world_chain_mainnet', + WORLD_CHAIN_SEPOLIA = 'world_chain_sepolia', + + SHAPE_MAINNET = 'shape_mainnet', + SHAPE_SEPOLIA = 'shape_sepolia', + + ZKSYNC_MAINNET = 'zksync_mainnet', + ZKSYNC_SEPOLIA = 'zksync_sepolia', + + STARKNET_MAINNET = 'starknet_mainnet', + STARKNET_SEPOLIA = 'starknet_sepolia', + + ZETACHAIN_MAINNET = 'zetachain_mainnet', + ZETACHAIN_TESTNET = 'zetachain_testnet', + + FANTOM_OPERA_MAINNET = 'fantom_opera_mainnet', + FANTOM_OPERA_TESTNET = 'fantom_opera_testnet', + + MANTLE_MAINNET = 'mantle_mainnet', + + BERACHAIN_ARTIO = 'berachain_artio', + + BLAST_MAINNET = 'blast_mainnet', + BLAST_SEPOLIA = 'blast_sepolia', + + LINEA_MAINNET = 'linea_mainnet', + LINEA_SEPOLIA = 'linea_sepolia', + + ZORA_MAINNET = 'zora_mainnet', + ZORA_SEPOLIA = 'zora_sepolia', + + POLYNOMIAL_MAINNET = 'polynomial_mainnet', + POLYNOMIAL_SEPOLIA = 'polynomial_sepolia', + + SCROLL_MAINNET = 'scroll_mainnet', + SCROLL_SEPOLIA = 'scroll_sepolia', + + FRAX_MAINNET = 'frax_mainnet', + FRAX_SEPOLIA = 'frax_sepolia', + + SOLANA_MAINNET = 'solana_mainnet', + SOLANA_DEVNET = 'solana_devnet', + + OPBNB_MAINNET = 'opbnb_mainnet', + OPBNB_TESTNET = 'opbnb_testnet', + + CROSSFI_TESTNET = 'crossfi_testnet', + + ASTAR_MAINNET = 'astar_mainnet', + + FLOW_EVM_TESTNET = 'flow_evm_testnet', + + SONEIUM_MINATO = 'soneium_minato', + + GEIST_POLTER = 'geist_polter', + + ROOTSTOCK_MAINNET = 'rootstock_mainnet', + ROOTSTOCK_TESTNET = 'rootstock_testnet', + + UNICHAIN_SEPOLIA = 'unichain_sepolia', + + GNOSIS_MAINNET = 'gnosis_mainnet', } // Combining the ws types diff --git a/packages/web3-rpc-providers/src/web3_provider_alchemy.ts b/packages/web3-rpc-providers/src/web3_provider_alchemy.ts index bf97c5fe5eb..8d62e38f644 100644 --- a/packages/web3-rpc-providers/src/web3_provider_alchemy.ts +++ b/packages/web3-rpc-providers/src/web3_provider_alchemy.ts @@ -37,14 +37,61 @@ export class AlchemyProvider extends Web3ExternalProvider { [Network.ETH_MAINNET]: 'eth-mainnet.g.alchemy.com', [Network.ETH_SEPOLIA]: 'eth-sepolia.g.alchemy.com', [Network.ETH_GOERLI]: 'eth-goerli.g.alchemy.com', + [Network.ETH_HOLESKY]: 'eth-holesky.g.alchemy.com', [Network.ARBITRUM_MAINNET]: 'arb-mainnet.g.alchemy.com', [Network.ARBITRUM_SEPOLIA]: 'arb-sepolia.g.alchemy.com', + [Network.ARBITRUM_NOVA_MAINNET]: 'arb-nova.g.alchemy.com', [Network.BASE_MAINNET]: 'base-mainnet.g.alchemy.com', [Network.BASE_SEPOLIA]: 'base-sepolia.g.alchemy.com', [Network.POLYGON_MAINNET]: 'polygon-mainnet.g.alchemy.com', + [Network.POLYGON_MUMBAI]: 'polygon-mumbai.g.alchemy.com', [Network.POLYGON_AMOY]: 'polygon-amoy.g.alchemy.com', + [Network.POLYGON_POS_MAINNET]: 'polygon-mainnet.g.alchemy.com', + [Network.POLYGON_ZKEVM_MAINNET]: 'polygonzkevm-mainnet.g.alchemy.com', + [Network.POLYGON_ZKEVM_CARDONA]: 'polygonzkevm-cardona.g.alchemy.com', [Network.OPTIMISM_MAINNET]: 'opt-mainnet.g.alchemy.com', [Network.OPTIMISM_SEPOLIA]: 'opt-sepolia.g.alchemy.com', + [Network.ASTAR_MAINNET]: 'astar-mainnet.g.alchemy.com', + [Network.WORLD_CHAIN_MAINNET]: 'worldchain-mainnet.g.alchemy.com', + [Network.WORLD_CHAIN_SEPOLIA]: 'worldchain-sepolia.g.alchemy.com', + [Network.SHAPE_MAINNET]: 'shape-mainnet.g.alchemy.com', + [Network.SHAPE_SEPOLIA]: 'shape-sepolia.g.alchemy.com', + [Network.ZKSYNC_MAINNET]: 'zksync-mainnet.g.alchemy.com', + [Network.ZKSYNC_SEPOLIA]: 'zksync-sepolia.g.alchemy.com', + [Network.STARKNET_MAINNET]: 'starknet-mainnet.g.alchemy.com', + [Network.STARKNET_SEPOLIA]: 'starknet-sepolia.g.alchemy.com', + [Network.ZETACHAIN_MAINNET]: 'zetachain-mainnet.g.alchemy.com', + [Network.ZETACHAIN_TESTNET]: 'zetachain-testnet.g.alchemy.com', + [Network.FANTOM_OPERA_MAINNET]: 'fantom-mainnet.g.alchemy.com', + [Network.FANTOM_OPERA_TESTNET]: 'fantom-testnet.g.alchemy.com', + [Network.MANTLE_MAINNET]: 'mantle-mainnet.g.alchemy.com', + [Network.BERACHAIN_ARTIO]: 'berachain-artio.g.alchemy.com', + [Network.BLAST_MAINNET]: 'blast-mainnet.g.alchemy.com', + [Network.BLAST_SEPOLIA]: 'blast-sepolia.g.alchemy.com', + [Network.LINEA_MAINNET]: 'linea-mainnet.g.alchemy.com', + [Network.LINEA_SEPOLIA]: 'linea-sepolia.g.alchemy.com', + [Network.ZORA_MAINNET]: 'zora-mainnet.g.alchemy.com', + [Network.ZORA_SEPOLIA]: 'zora-sepolia.g.alchemy.com', + [Network.POLYNOMIAL_MAINNET]: 'polynomial-mainnet.g.alchemy.com', + [Network.POLYNOMIAL_SEPOLIA]: 'polynomial-sepolia.g.alchemy.com', + [Network.SCROLL_MAINNET]: 'scroll-mainnet.g.alchemy.com', + [Network.SCROLL_SEPOLIA]: 'scroll-sepolia.g.alchemy.com', + [Network.FRAX_MAINNET]: 'frax-mainnet.g.alchemy.com', + [Network.FRAX_SEPOLIA]: 'frax-sepolia.g.alchemy.com', + [Network.SOLANA_MAINNET]: 'solana-mainnet.g.alchemy.com', + [Network.SOLANA_DEVNET]: 'solana-devnet.g.alchemy.com', + [Network.CROSSFI_TESTNET]: 'crossfi-testnet.g.alchemy.com', + [Network.FLOW_EVM_TESTNET]: 'flow-testnet.g.alchemy.com', + [Network.SONEIUM_MINATO]: 'soneium-minato.g.alchemy.com', + [Network.GEIST_POLTER]: 'geist-polter.g.alchemy.com', + [Network.ROOTSTOCK_MAINNET]: 'rootstock-mainnet.g.alchemy.com', + [Network.ROOTSTOCK_TESTNET]: 'rootstock-testnet.g.alchemy.com', + [Network.UNICHAIN_SEPOLIA]: 'unichain-sepolia.g.alchemy.com', + [Network.GNOSIS_MAINNET]: 'gnosis-mainnet.g.alchemy.com', + [Network.BNB_MAINNET]: 'bnb-mainnet.g.alchemy.com', + [Network.BNB_TESTNET]: 'bnb-testnet.g.alchemy.com', + [Network.OPBNB_MAINNET]: 'opbnb-mainnet.g.alchemy.com', + [Network.OPBNB_TESTNET]: 'opbnb-testnet.g.alchemy.com', }; // eslint-disable-next-line class-methods-use-this From 2982118d5088ccbc64f678798016a64215713b5a Mon Sep 17 00:00:00 2001 From: Mario Rivera Date: Mon, 21 Oct 2024 20:35:11 -0400 Subject: [PATCH 09/10] Make a separate test loop for Alchemy networks and use a specific network list --- .../test/integration/web3RPCProviders.test.ts | 68 ++++++++++++++++++- 1 file changed, 66 insertions(+), 2 deletions(-) diff --git a/packages/web3/test/integration/web3RPCProviders.test.ts b/packages/web3/test/integration/web3RPCProviders.test.ts index 1bf6300f5d8..20296bcd9b5 100644 --- a/packages/web3/test/integration/web3RPCProviders.test.ts +++ b/packages/web3/test/integration/web3RPCProviders.test.ts @@ -26,7 +26,7 @@ import { Web3 } from '../../src/index'; describe('Web3 RPC Provider Integration tests', () => { const transports = Object.values(Transport); - const networks = [ + const quickNodeNetworks = [ Network.ETH_MAINNET, Network.ETH_HOLESKY, Network.ETH_SEPOLIA, @@ -39,7 +39,7 @@ describe('Web3 RPC Provider Integration tests', () => { ]; transports.forEach(transport => { - networks.forEach(network => { + quickNodeNetworks.forEach(network => { it(`QuickNodeProvider should work with ${transport} transport and ${network} network`, async () => { const provider = new QuickNodeProvider(network, transport); const web3 = new Web3(provider); @@ -52,6 +52,70 @@ describe('Web3 RPC Provider Integration tests', () => { web3.provider?.disconnect(); } }); + }); + + const alchemyNetworks = [ + Network.ETH_MAINNET, + Network.ETH_SEPOLIA, + Network.ETH_GOERLI, + Network.ETH_HOLESKY, + Network.ARBITRUM_MAINNET, + Network.ARBITRUM_SEPOLIA, + Network.ARBITRUM_NOVA_MAINNET, + Network.BASE_MAINNET, + Network.BASE_SEPOLIA, + Network.POLYGON_MAINNET, + Network.POLYGON_MUMBAI, + Network.POLYGON_AMOY, + Network.POLYGON_POS_MAINNET, + Network.POLYGON_ZKEVM_MAINNET, + Network.POLYGON_ZKEVM_CARDONA, + Network.OPTIMISM_MAINNET, + Network.OPTIMISM_SEPOLIA, + Network.ASTAR_MAINNET, + Network.WORLD_CHAIN_MAINNET, + Network.WORLD_CHAIN_SEPOLIA, + Network.SHAPE_MAINNET, + Network.SHAPE_SEPOLIA, + Network.ZKSYNC_MAINNET, + Network.ZKSYNC_SEPOLIA, + Network.STARKNET_MAINNET, + Network.STARKNET_SEPOLIA, + Network.ZETACHAIN_MAINNET, + Network.ZETACHAIN_TESTNET, + Network.FANTOM_OPERA_MAINNET, + Network.FANTOM_OPERA_TESTNET, + Network.MANTLE_MAINNET, + Network.BERACHAIN_ARTIO, + Network.BLAST_MAINNET, + Network.BLAST_SEPOLIA, + Network.LINEA_MAINNET, + Network.LINEA_SEPOLIA, + Network.ZORA_MAINNET, + Network.ZORA_SEPOLIA, + Network.POLYNOMIAL_MAINNET, + Network.POLYNOMIAL_SEPOLIA, + Network.SCROLL_MAINNET, + Network.SCROLL_SEPOLIA, + Network.FRAX_MAINNET, + Network.FRAX_SEPOLIA, + Network.SOLANA_MAINNET, + Network.SOLANA_DEVNET, + Network.CROSSFI_TESTNET, + Network.FLOW_EVM_TESTNET, + Network.SONEIUM_MINATO, + Network.GEIST_POLTER, + Network.ROOTSTOCK_MAINNET, + Network.ROOTSTOCK_TESTNET, + Network.UNICHAIN_SEPOLIA, + Network.GNOSIS_MAINNET, + Network.BNB_MAINNET, + Network.BNB_TESTNET, + Network.OPBNB_MAINNET, + Network.OPBNB_TESTNET, + ]; + + alchemyNetworks.forEach(network => { it(`AlchemyProvider should work with ${transport} transport and ${network} network`, async () => { const provider = new AlchemyProvider(network, transport); const web3 = new Web3(provider); From 45c1b8a78e69da9a25e53e1702f1c23737313c40 Mon Sep 17 00:00:00 2001 From: Mario Rivera Date: Wed, 30 Oct 2024 08:55:57 -0400 Subject: [PATCH 10/10] ETH Goerli has been removed --- packages/web3-rpc-providers/src/web3_provider_alchemy.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/web3-rpc-providers/src/web3_provider_alchemy.ts b/packages/web3-rpc-providers/src/web3_provider_alchemy.ts index 8d62e38f644..750bb348d0b 100644 --- a/packages/web3-rpc-providers/src/web3_provider_alchemy.ts +++ b/packages/web3-rpc-providers/src/web3_provider_alchemy.ts @@ -36,7 +36,6 @@ export class AlchemyProvider extends Web3ExternalProvider { public static readonly networkStringMap: { [key: string]: string } = { [Network.ETH_MAINNET]: 'eth-mainnet.g.alchemy.com', [Network.ETH_SEPOLIA]: 'eth-sepolia.g.alchemy.com', - [Network.ETH_GOERLI]: 'eth-goerli.g.alchemy.com', [Network.ETH_HOLESKY]: 'eth-holesky.g.alchemy.com', [Network.ARBITRUM_MAINNET]: 'arb-mainnet.g.alchemy.com', [Network.ARBITRUM_SEPOLIA]: 'arb-sepolia.g.alchemy.com',