Skip to content

Commit 00fd4c0

Browse files
authored
refactor: remove alchemy block source (#58)
1 parent bdd3abb commit 00fd4c0

5 files changed

Lines changed: 26 additions & 129 deletions

File tree

src/sdk/builders/blocks-builder.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ import { BlocksService } from '@services/blocks/block-service';
55
import { IProviderService } from '@services/providers';
66
import { RPCBlockSource } from '@services/blocks/block-sources/rpc-block-source';
77
import { FallbackBlockSource } from '@services/blocks/block-sources/fallback-block-source';
8-
import { AlchemyBlockSource } from '@services/blocks/block-sources/alchemy-block-source';
98

109
export type BlocksSourceInput =
1110
| { type: 'custom'; instance: IBlocksSource }
1211
| { type: 'custom-with-underlying'; underlyingSource: BlocksSourceInput; build: (underlying: IBlocksSource) => IBlocksSource }
1312
| { type: 'defi-llama' }
1413
| { type: 'rpc' }
15-
| { type: 'alchemy'; apiKey: string }
1614
| { type: 'fallback'; sources: BlocksSourceInput[] };
1715
export type BuildBlocksParams = { source: BlocksSourceInput };
1816

@@ -35,8 +33,6 @@ function buildSource(
3533
return new DefiLlamaBlockSource(fetchService, providerService);
3634
case 'rpc':
3735
return new RPCBlockSource(providerService);
38-
case 'alchemy':
39-
return new AlchemyBlockSource({ key: source.apiKey, fetchService, providerService });
4036
case 'fallback':
4137
return new FallbackBlockSource(source.sources.map((source) => buildSource(source, { fetchService, providerService })));
4238
case 'custom':

src/services/blocks/block-sources/alchemy-block-source.ts

Lines changed: 0 additions & 90 deletions
This file was deleted.

src/shared/alchemy.ts

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,33 @@
11
import { Chains } from '@chains';
22
import { ChainId } from '@types';
33

4-
export const ALCHEMY_NETWORKS: Record<ChainId, { key: string; price: { supported: boolean }; blocks: { supported: boolean } }> = {
5-
[Chains.ETHEREUM.chainId]: { key: 'eth-mainnet', price: { supported: true }, blocks: { supported: true } },
6-
[Chains.ETHEREUM_SEPOLIA.chainId]: { key: 'eth-sepolia', price: { supported: false }, blocks: { supported: false } },
7-
[Chains.OPTIMISM.chainId]: { key: 'opt-mainnet', price: { supported: true }, blocks: { supported: true } },
8-
[Chains.ARBITRUM.chainId]: { key: 'arb-mainnet', price: { supported: true }, blocks: { supported: true } },
9-
[Chains.POLYGON.chainId]: { key: 'polygon-mainnet', price: { supported: true }, blocks: { supported: true } },
10-
[Chains.POLYGON_MUMBAI.chainId]: { key: 'polygon-mumbai', price: { supported: false }, blocks: { supported: false } },
11-
[Chains.ASTAR.chainId]: { key: 'astar-mainnet', price: { supported: false }, blocks: { supported: false } },
12-
[Chains.BLAST.chainId]: { key: 'blast-mainnet', price: { supported: true }, blocks: { supported: true } },
13-
[Chains.BNB_CHAIN.chainId]: { key: 'bnb-mainnet', price: { supported: true }, blocks: { supported: true } },
14-
[Chains.AVALANCHE.chainId]: { key: 'avax-mainnet', price: { supported: true }, blocks: { supported: true } },
15-
[Chains.FANTOM.chainId]: { key: 'fantom-mainnet', price: { supported: true }, blocks: { supported: false } },
16-
[Chains.METIS_ANDROMEDA.chainId]: { key: 'metis-mainnet', price: { supported: true }, blocks: { supported: false } },
4+
export const ALCHEMY_NETWORKS: Record<ChainId, { key: string; price: { supported: boolean } }> = {
5+
[Chains.ETHEREUM.chainId]: { key: 'eth-mainnet', price: { supported: true } },
6+
[Chains.ETHEREUM_SEPOLIA.chainId]: { key: 'eth-sepolia', price: { supported: false } },
7+
[Chains.OPTIMISM.chainId]: { key: 'opt-mainnet', price: { supported: true } },
8+
[Chains.ARBITRUM.chainId]: { key: 'arb-mainnet', price: { supported: true } },
9+
[Chains.POLYGON.chainId]: { key: 'polygon-mainnet', price: { supported: true } },
10+
[Chains.POLYGON_MUMBAI.chainId]: { key: 'polygon-mumbai', price: { supported: false } },
11+
[Chains.ASTAR.chainId]: { key: 'astar-mainnet', price: { supported: false } },
12+
[Chains.BLAST.chainId]: { key: 'blast-mainnet', price: { supported: true } },
13+
[Chains.BNB_CHAIN.chainId]: { key: 'bnb-mainnet', price: { supported: true } },
14+
[Chains.AVALANCHE.chainId]: { key: 'avax-mainnet', price: { supported: true } },
15+
[Chains.FANTOM.chainId]: { key: 'fantom-mainnet', price: { supported: true } },
16+
[Chains.METIS_ANDROMEDA.chainId]: { key: 'metis-mainnet', price: { supported: true } },
1717
[Chains.POLYGON_ZKEVM.chainId]: {
1818
key: 'polygonzkevm-mainnet',
1919
price: { supported: true },
20-
blocks: { supported: false },
2120
},
22-
[Chains.BASE.chainId]: { key: 'base-mainnet', price: { supported: true }, blocks: { supported: true } },
23-
[Chains.GNOSIS.chainId]: { key: 'gnosis-mainnet', price: { supported: true }, blocks: { supported: false } },
24-
[Chains.SCROLL.chainId]: { key: 'scroll-mainnet', price: { supported: true }, blocks: { supported: false } },
25-
[Chains.opBNB.chainId]: { key: 'opbnb-mainnet', price: { supported: true }, blocks: { supported: false } },
26-
[Chains.MANTLE.chainId]: { key: 'mantle-mainnet', price: { supported: false }, blocks: { supported: false } },
27-
[Chains.ROOTSTOCK.chainId]: { key: 'rootstock-mainnet', price: { supported: false }, blocks: { supported: false } },
28-
[Chains.LINEA.chainId]: { key: 'linea-mainnet', price: { supported: true }, blocks: { supported: false } },
29-
[Chains.SONIC.chainId]: { key: 'sonic-mainnet', price: { supported: false }, blocks: { supported: false } },
30-
[Chains.ZK_SYNC_ERA.chainId]: { key: 'zksync-mainnet', price: { supported: true }, blocks: { supported: true } },
31-
[Chains.CELO.chainId]: { key: 'celo-mainnet', price: { supported: false }, blocks: { supported: true } },
32-
[Chains.PLASMA.chainId]: { key: 'plasma-mainnet', price: { supported: false }, blocks: { supported: false } },
33-
[Chains.UNICHAIN.chainId]: { key: 'unichain-mainnet', price: { supported: false }, blocks: { supported: false } },
21+
[Chains.BASE.chainId]: { key: 'base-mainnet', price: { supported: true } },
22+
[Chains.GNOSIS.chainId]: { key: 'gnosis-mainnet', price: { supported: true } },
23+
[Chains.SCROLL.chainId]: { key: 'scroll-mainnet', price: { supported: true } },
24+
[Chains.opBNB.chainId]: { key: 'opbnb-mainnet', price: { supported: true } },
25+
[Chains.MANTLE.chainId]: { key: 'mantle-mainnet', price: { supported: false } },
26+
[Chains.ROOTSTOCK.chainId]: { key: 'rootstock-mainnet', price: { supported: false } },
27+
[Chains.LINEA.chainId]: { key: 'linea-mainnet', price: { supported: true } },
28+
[Chains.SONIC.chainId]: { key: 'sonic-mainnet', price: { supported: false } },
29+
[Chains.ZK_SYNC_ERA.chainId]: { key: 'zksync-mainnet', price: { supported: true } },
30+
[Chains.CELO.chainId]: { key: 'celo-mainnet', price: { supported: false } },
31+
[Chains.PLASMA.chainId]: { key: 'plasma-mainnet', price: { supported: false } },
32+
[Chains.UNICHAIN.chainId]: { key: 'unichain-mainnet', price: { supported: false } },
3433
};

src/shared/defi-llama.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const CHAIN_ID_TO_KEY: Record<ChainId, Lowercase<string>> = {
2727
[Chains.VELAS.chainId]: 'velas',
2828
[Chains.ROOTSTOCK.chainId]: 'rsk',
2929
[Chains.EVMOS.chainId]: 'evmos',
30-
[Chains.CANTO.chainId]: 'canto',
3130
[Chains.POLYGON_ZKEVM.chainId]: 'polygon_zkevm',
3231
[Chains.KAVA.chainId]: 'kava',
3332
[Chains.BASE.chainId]: 'base',

test/integration/services/blocks/block-sources.spec.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { BlockResult, IBlocksSource } from '@services/blocks';
1111
import { ProviderService } from '@services/providers/provider-service';
1212
import { PublicRPCsProviderSource } from '@services/providers/provider-sources/public-rpcs-provider';
1313
import { FallbackBlockSource } from '@services/blocks/block-sources/fallback-block-source';
14-
import { AlchemyBlockSource } from '@services/blocks/block-sources/alchemy-block-source';
1514
import { AlchemyProviderSource } from '@services/providers/provider-sources/alchemy-provider';
1615
dotenv.config();
1716
chai.use(chaiAsPromised);
@@ -37,20 +36,14 @@ const FETCH_SERVICE = new FetchService();
3736
const DEFI_LLAMA_BLOCKS_SOURCE = new DefiLlamaBlockSource(FETCH_SERVICE, PROVIDER_SERVICE);
3837
const RPC_BLOCKS_SOURCE = new RPCBlockSource(PROVIDER_SERVICE);
3938
const FALLBACK_BLOCK_SOURCE = new FallbackBlockSource([RPC_BLOCKS_SOURCE, DEFI_LLAMA_BLOCKS_SOURCE]);
40-
const ALCHEMY_BLOCK_SOURCE = new AlchemyBlockSource({
41-
key: process.env.ALCHEMY_API_KEY!,
42-
fetchService: FETCH_SERVICE,
43-
providerService: PROVIDER_SERVICE,
44-
});
4539

4640
jest.retryTimes(2);
4741
jest.setTimeout(ms('3m'));
4842

4943
describe('Blocks Sources', () => {
50-
// blocksSourceTest({ title: 'Defi Llama Source', source: DEFI_LLAMA_BLOCKS_SOURCE }); DefiLlama is not passing tests since they sometimes return a block that is not exactly the closed, but the second closest
44+
// blocksSourceTest({ title: 'Defi Llama Source', source: DEFI_LLAMA_BLOCKS_SOURCE }); DefiLlama is not passing tests since they sometimes return a block that is not exactly the closest, but the second closest
5145
blocksSourceTest({ title: 'RPC Source', source: RPC_BLOCKS_SOURCE });
5246
blocksSourceTest({ title: 'Fallback Source', source: FALLBACK_BLOCK_SOURCE });
53-
blocksSourceTest({ title: 'Alchemy Source', source: ALCHEMY_BLOCK_SOURCE });
5447

5548
function blocksSourceTest({ title, source }: { title: string; source: IBlocksSource }) {
5649
describe(title, () => {

0 commit comments

Comments
 (0)