Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/sdk/builders/blocks-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import { BlocksService } from '@services/blocks/block-service';
import { IProviderService } from '@services/providers';
import { RPCBlockSource } from '@services/blocks/block-sources/rpc-block-source';
import { FallbackBlockSource } from '@services/blocks/block-sources/fallback-block-source';
import { AlchemyBlockSource } from '@services/blocks/block-sources/alchemy-block-source';

export type BlocksSourceInput =
| { type: 'custom'; instance: IBlocksSource }
| { type: 'custom-with-underlying'; underlyingSource: BlocksSourceInput; build: (underlying: IBlocksSource) => IBlocksSource }
| { type: 'defi-llama' }
| { type: 'rpc' }
| { type: 'alchemy'; apiKey: string }
| { type: 'fallback'; sources: BlocksSourceInput[] };
export type BuildBlocksParams = { source: BlocksSourceInput };

Expand All @@ -35,8 +33,6 @@ function buildSource(
return new DefiLlamaBlockSource(fetchService, providerService);
case 'rpc':
return new RPCBlockSource(providerService);
case 'alchemy':
return new AlchemyBlockSource({ key: source.apiKey, fetchService, providerService });
case 'fallback':
return new FallbackBlockSource(source.sources.map((source) => buildSource(source, { fetchService, providerService })));
case 'custom':
Expand Down
90 changes: 0 additions & 90 deletions src/services/blocks/block-sources/alchemy-block-source.ts

This file was deleted.

51 changes: 25 additions & 26 deletions src/shared/alchemy.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
import { Chains } from '@chains';
import { ChainId } from '@types';

export const ALCHEMY_NETWORKS: Record<ChainId, { key: string; price: { supported: boolean }; blocks: { supported: boolean } }> = {
[Chains.ETHEREUM.chainId]: { key: 'eth-mainnet', price: { supported: true }, blocks: { supported: true } },
[Chains.ETHEREUM_SEPOLIA.chainId]: { key: 'eth-sepolia', price: { supported: false }, blocks: { supported: false } },
[Chains.OPTIMISM.chainId]: { key: 'opt-mainnet', price: { supported: true }, blocks: { supported: true } },
[Chains.ARBITRUM.chainId]: { key: 'arb-mainnet', price: { supported: true }, blocks: { supported: true } },
[Chains.POLYGON.chainId]: { key: 'polygon-mainnet', price: { supported: true }, blocks: { supported: true } },
[Chains.POLYGON_MUMBAI.chainId]: { key: 'polygon-mumbai', price: { supported: false }, blocks: { supported: false } },
[Chains.ASTAR.chainId]: { key: 'astar-mainnet', price: { supported: false }, blocks: { supported: false } },
[Chains.BLAST.chainId]: { key: 'blast-mainnet', price: { supported: true }, blocks: { supported: true } },
[Chains.BNB_CHAIN.chainId]: { key: 'bnb-mainnet', price: { supported: true }, blocks: { supported: true } },
[Chains.AVALANCHE.chainId]: { key: 'avax-mainnet', price: { supported: true }, blocks: { supported: true } },
[Chains.FANTOM.chainId]: { key: 'fantom-mainnet', price: { supported: true }, blocks: { supported: false } },
[Chains.METIS_ANDROMEDA.chainId]: { key: 'metis-mainnet', price: { supported: true }, blocks: { supported: false } },
export const ALCHEMY_NETWORKS: Record<ChainId, { key: string; price: { supported: boolean } }> = {
[Chains.ETHEREUM.chainId]: { key: 'eth-mainnet', price: { supported: true } },
[Chains.ETHEREUM_SEPOLIA.chainId]: { key: 'eth-sepolia', price: { supported: false } },
[Chains.OPTIMISM.chainId]: { key: 'opt-mainnet', price: { supported: true } },
[Chains.ARBITRUM.chainId]: { key: 'arb-mainnet', price: { supported: true } },
[Chains.POLYGON.chainId]: { key: 'polygon-mainnet', price: { supported: true } },
[Chains.POLYGON_MUMBAI.chainId]: { key: 'polygon-mumbai', price: { supported: false } },
[Chains.ASTAR.chainId]: { key: 'astar-mainnet', price: { supported: false } },
[Chains.BLAST.chainId]: { key: 'blast-mainnet', price: { supported: true } },
[Chains.BNB_CHAIN.chainId]: { key: 'bnb-mainnet', price: { supported: true } },
[Chains.AVALANCHE.chainId]: { key: 'avax-mainnet', price: { supported: true } },
[Chains.FANTOM.chainId]: { key: 'fantom-mainnet', price: { supported: true } },
[Chains.METIS_ANDROMEDA.chainId]: { key: 'metis-mainnet', price: { supported: true } },
[Chains.POLYGON_ZKEVM.chainId]: {
key: 'polygonzkevm-mainnet',
price: { supported: true },
blocks: { supported: false },
},
[Chains.BASE.chainId]: { key: 'base-mainnet', price: { supported: true }, blocks: { supported: true } },
[Chains.GNOSIS.chainId]: { key: 'gnosis-mainnet', price: { supported: true }, blocks: { supported: false } },
[Chains.SCROLL.chainId]: { key: 'scroll-mainnet', price: { supported: true }, blocks: { supported: false } },
[Chains.opBNB.chainId]: { key: 'opbnb-mainnet', price: { supported: true }, blocks: { supported: false } },
[Chains.MANTLE.chainId]: { key: 'mantle-mainnet', price: { supported: false }, blocks: { supported: false } },
[Chains.ROOTSTOCK.chainId]: { key: 'rootstock-mainnet', price: { supported: false }, blocks: { supported: false } },
[Chains.LINEA.chainId]: { key: 'linea-mainnet', price: { supported: true }, blocks: { supported: false } },
[Chains.SONIC.chainId]: { key: 'sonic-mainnet', price: { supported: false }, blocks: { supported: false } },
[Chains.ZK_SYNC_ERA.chainId]: { key: 'zksync-mainnet', price: { supported: true }, blocks: { supported: true } },
[Chains.CELO.chainId]: { key: 'celo-mainnet', price: { supported: false }, blocks: { supported: true } },
[Chains.PLASMA.chainId]: { key: 'plasma-mainnet', price: { supported: false }, blocks: { supported: false } },
[Chains.UNICHAIN.chainId]: { key: 'unichain-mainnet', price: { supported: false }, blocks: { supported: false } },
[Chains.BASE.chainId]: { key: 'base-mainnet', price: { supported: true } },
[Chains.GNOSIS.chainId]: { key: 'gnosis-mainnet', price: { supported: true } },
[Chains.SCROLL.chainId]: { key: 'scroll-mainnet', price: { supported: true } },
[Chains.opBNB.chainId]: { key: 'opbnb-mainnet', price: { supported: true } },
[Chains.MANTLE.chainId]: { key: 'mantle-mainnet', price: { supported: false } },
[Chains.ROOTSTOCK.chainId]: { key: 'rootstock-mainnet', price: { supported: false } },
[Chains.LINEA.chainId]: { key: 'linea-mainnet', price: { supported: true } },
[Chains.SONIC.chainId]: { key: 'sonic-mainnet', price: { supported: false } },
[Chains.ZK_SYNC_ERA.chainId]: { key: 'zksync-mainnet', price: { supported: true } },
[Chains.CELO.chainId]: { key: 'celo-mainnet', price: { supported: false } },
[Chains.PLASMA.chainId]: { key: 'plasma-mainnet', price: { supported: false } },
[Chains.UNICHAIN.chainId]: { key: 'unichain-mainnet', price: { supported: false } },
};
1 change: 0 additions & 1 deletion src/shared/defi-llama.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const CHAIN_ID_TO_KEY: Record<ChainId, Lowercase<string>> = {
[Chains.VELAS.chainId]: 'velas',
[Chains.ROOTSTOCK.chainId]: 'rsk',
[Chains.EVMOS.chainId]: 'evmos',
[Chains.CANTO.chainId]: 'canto',
[Chains.POLYGON_ZKEVM.chainId]: 'polygon_zkevm',
[Chains.KAVA.chainId]: 'kava',
[Chains.BASE.chainId]: 'base',
Expand Down
9 changes: 1 addition & 8 deletions test/integration/services/blocks/block-sources.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { BlockResult, IBlocksSource } from '@services/blocks';
import { ProviderService } from '@services/providers/provider-service';
import { PublicRPCsProviderSource } from '@services/providers/provider-sources/public-rpcs-provider';
import { FallbackBlockSource } from '@services/blocks/block-sources/fallback-block-source';
import { AlchemyBlockSource } from '@services/blocks/block-sources/alchemy-block-source';
import { AlchemyProviderSource } from '@services/providers/provider-sources/alchemy-provider';
dotenv.config();
chai.use(chaiAsPromised);
Expand All @@ -37,20 +36,14 @@ const FETCH_SERVICE = new FetchService();
const DEFI_LLAMA_BLOCKS_SOURCE = new DefiLlamaBlockSource(FETCH_SERVICE, PROVIDER_SERVICE);
const RPC_BLOCKS_SOURCE = new RPCBlockSource(PROVIDER_SERVICE);
const FALLBACK_BLOCK_SOURCE = new FallbackBlockSource([RPC_BLOCKS_SOURCE, DEFI_LLAMA_BLOCKS_SOURCE]);
const ALCHEMY_BLOCK_SOURCE = new AlchemyBlockSource({
key: process.env.ALCHEMY_API_KEY!,
fetchService: FETCH_SERVICE,
providerService: PROVIDER_SERVICE,
});

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

describe('Blocks Sources', () => {
// 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
// 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
blocksSourceTest({ title: 'RPC Source', source: RPC_BLOCKS_SOURCE });
blocksSourceTest({ title: 'Fallback Source', source: FALLBACK_BLOCK_SOURCE });
blocksSourceTest({ title: 'Alchemy Source', source: ALCHEMY_BLOCK_SOURCE });

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