[Blockchain Watcher] (FIX ARBITRUM) Export environment variable to validate env (#1181)

* Export environment

* Resolve test

---------

Co-authored-by: julian merlo <julianmerlo@julians-MacBook-Pro.local>
This commit is contained in:
Julian 2024-03-05 16:10:49 -03:00 committed by GitHub
parent a55dbc6ccc
commit fa6196b02c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 11 additions and 6 deletions

View File

@ -96,6 +96,7 @@ export class RepositoriesBuilder {
const pools = this.createEvmProviderPools(); const pools = this.createEvmProviderPools();
const repoCfg: EvmJsonRPCBlockRepositoryCfg = { const repoCfg: EvmJsonRPCBlockRepositoryCfg = {
chains: this.cfg.chains, chains: this.cfg.chains,
environment: this.cfg.environment,
}; };
const moonbeamRepository = new RateLimitedEvmJsonRPCBlockRepository( const moonbeamRepository = new RateLimitedEvmJsonRPCBlockRepository(

View File

@ -63,10 +63,7 @@ export class ArbitrumEvmJsonRPCBlockRepository extends EvmJsonRPCBlockRepository
this.saveAssociatedL1Block(auxPersistedBlocks, associatedL1ArbBlock, l2BlockArbNumber); this.saveAssociatedL1Block(auxPersistedBlocks, associatedL1ArbBlock, l2BlockArbNumber);
// Get the latest finalized L1 block ethereum number // Get the latest finalized L1 block ethereum number
const latestL1BlockEthNumber: bigint = await super.getBlockHeight( const latestL1BlockEthNumber: bigint = await super.getBlockHeight(this.getL1Chain(), FINALIZED);
this.getL1Chain(chain),
FINALIZED
);
// Search in the persisted list looking for finalized L2 block number // Search in the persisted list looking for finalized L2 block number
this.searchFinalizedBlock(auxPersistedBlocks, latestL1BlockEthNumber); this.searchFinalizedBlock(auxPersistedBlocks, latestL1BlockEthNumber);
@ -139,8 +136,8 @@ export class ArbitrumEvmJsonRPCBlockRepository extends EvmJsonRPCBlockRepository
} }
} }
private getL1Chain(chain: string): string { private getL1Chain(): string {
return chain === "arbitrum" ? "ethereum" : "ethereum-sepolia"; return this.cfg.environment === "testnet" ? "ethereum-sepolia" : "ethereum";
} }
} }

View File

@ -362,6 +362,7 @@ export class EvmJsonRPCBlockRepository implements EvmBlockRepository {
export type EvmJsonRPCBlockRepositoryCfg = { export type EvmJsonRPCBlockRepositoryCfg = {
chains: Record<string, ChainRPCConfig>; chains: Record<string, ChainRPCConfig>;
environment: string;
}; };
type ErrorBlock = { type ErrorBlock = {

View File

@ -89,6 +89,7 @@ const givenARepo = () => {
chainId: 23, chainId: 23,
}, },
}, },
environment: "mainnet",
}, },
{ {
ethereum: { get: () => new InstrumentedHttpProvider({ url: rpc, chain: "ethereum" }) }, ethereum: { get: () => new InstrumentedHttpProvider({ url: rpc, chain: "ethereum" }) },

View File

@ -45,6 +45,7 @@ const givenARepo = () => {
chains: { chains: {
bsc: { rpcs: [rpc], timeout: 100, name: bsc, network: "mainnet", chainId: 4 }, bsc: { rpcs: [rpc], timeout: 100, name: bsc, network: "mainnet", chainId: 4 },
}, },
environment: "testnet",
}, },
{ bsc: { get: () => new InstrumentedHttpProvider({ url: rpc, chain: "bsc" }) } } as any { bsc: { get: () => new InstrumentedHttpProvider({ url: rpc, chain: "bsc" }) } } as any
); );

View File

@ -109,6 +109,7 @@ const givenARepo = () => {
chains: { chains: {
ethereum: { rpcs: [rpc], timeout: 100, name: "ethereum", network: "mainnet", chainId: 2 }, ethereum: { rpcs: [rpc], timeout: 100, name: "ethereum", network: "mainnet", chainId: 2 },
}, },
environment: "testnet",
}, },
{ {
ethereum: { get: () => new InstrumentedHttpProvider({ url: rpc, chain: "ethereum" }) }, ethereum: { get: () => new InstrumentedHttpProvider({ url: rpc, chain: "ethereum" }) },

View File

@ -47,6 +47,7 @@ const givenARepo = () => {
chains: { chains: {
moonbeam: { rpcs: [rpc], timeout: 100, name: moonbeam, network: "mainnet", chainId: 16 }, moonbeam: { rpcs: [rpc], timeout: 100, name: moonbeam, network: "mainnet", chainId: 16 },
}, },
environment: "testnet",
}, },
{ {
moonbeam: { get: () => new InstrumentedHttpProvider({ url: rpc, chain: "moonbeam" }) }, moonbeam: { get: () => new InstrumentedHttpProvider({ url: rpc, chain: "moonbeam" }) },

View File

@ -25,6 +25,7 @@ ETHEREUM_RPCS=
OPTIMISM_RPCS= OPTIMISM_RPCS=
ARBITRUM_RPCS= ARBITRUM_RPCS=
POLYGON_RPCS= POLYGON_RPCS=
MOONBEAM_RPCS=
AVALANCHE_RPCS= AVALANCHE_RPCS=
BASE_RPCS= BASE_RPCS=
BSC_RPCS= BSC_RPCS=

View File

@ -29,6 +29,7 @@ AVALANCHE_RPCS=
BASE_RPCS= BASE_RPCS=
BSC_RPCS= BSC_RPCS=
CELO_RPCS= CELO_RPCS=
MOONBEAM_RPCS=
SOLANA_RATE_LIMIT_LIMIT=15 SOLANA_RATE_LIMIT_LIMIT=15
SOLANA_RPCS= SOLANA_RPCS=