Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcontracts committed Aug 26, 2021
1 parent e9fa961 commit 7fb268f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
19 changes: 12 additions & 7 deletions packages/data-transport-layer/src/services/l1-ingestion/service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Imports: External */
import { fromHexString } from '@eth-optimism/core-utils'
import { BaseService, Metrics } from '@eth-optimism/common-ts'
import { StaticJsonRpcProvider } from '@ethersproject/providers'
import { FallbackProvider, StaticJsonRpcProvider } from '@ethersproject/providers'
import { LevelUp } from 'levelup'
import { ethers, constants } from 'ethers'
import { Gauge, Counter } from 'prom-client'
Expand Down Expand Up @@ -80,7 +80,7 @@ const optionSettings = {
},
l1RpcProvider: {
validate: (val: any) => {
return validators.isUrl(val) || validators.isJsonRpcProvider(val)
return validators.isString(val) || validators.isJsonRpcProvider(val)
},
},
l2ChainId: {
Expand All @@ -98,7 +98,7 @@ export class L1IngestionService extends BaseService<L1IngestionServiceOptions> {
private state: {
db: TransportDB
contracts: OptimismContracts
l1RpcProvider: StaticJsonRpcProvider
l1RpcProvider: FallbackProvider
startingL1BlockNumber: number
} = {} as any

Expand All @@ -107,10 +107,15 @@ export class L1IngestionService extends BaseService<L1IngestionServiceOptions> {

this.l1IngestionMetrics = registerMetrics(this.metrics)

this.state.l1RpcProvider =
typeof this.options.l1RpcProvider === 'string'
? new StaticJsonRpcProvider(this.options.l1RpcProvider)
: this.options.l1RpcProvider
if (typeof this.options.l1RpcProvider === 'string') {
const providerUrls = this.options.l1RpcProvider.split(',')
const providers = providerUrls.map((providerUrl) => {
return new StaticJsonRpcProvider(providerUrl)
})
this.state.l1RpcProvider = new FallbackProvider(providers)
} else {
this.state.l1RpcProvider = this.options.l1RpcProvider
}

this.logger.info('Using AddressManager', {
addressManager: this.options.addressManager,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { JsonRpcProvider } from '@ethersproject/providers'
import { BaseProvider } from '@ethersproject/providers'
import { BigNumber, Event } from 'ethers'

import { TransportDB } from '../db/transport-db'
Expand All @@ -15,7 +15,7 @@ export type TypedEthersEvent<T> = Event & {

export type GetExtraDataHandler<TEventArgs, TExtraData> = (
event?: TypedEthersEvent<TEventArgs>,
l1RpcProvider?: JsonRpcProvider
l1RpcProvider?: BaseProvider
) => Promise<TExtraData>

export type ParseEventHandler<TEventArgs, TExtraData, TParsedEvent> = (
Expand Down
8 changes: 4 additions & 4 deletions packages/data-transport-layer/src/utils/contracts.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* Imports: External */
import { constants, Contract, Signer } from 'ethers'
import { JsonRpcProvider } from '@ethersproject/providers'
import { BaseProvider } from '@ethersproject/providers'
import { getContractInterface } from '@eth-optimism/contracts'

export const loadContract = (
name: string,
address: string,
provider: JsonRpcProvider
provider: BaseProvider
): Contract => {
return new Contract(address, getContractInterface(name) as any, provider)
}
Expand All @@ -15,7 +15,7 @@ export const loadProxyFromManager = async (
name: string,
proxy: string,
Lib_AddressManager: Contract,
provider: JsonRpcProvider
provider: BaseProvider
): Promise<Contract> => {
const address = await Lib_AddressManager.getAddress(proxy)

Expand All @@ -36,7 +36,7 @@ export interface OptimismContracts {
}

export const loadOptimismContracts = async (
l1RpcProvider: JsonRpcProvider,
l1RpcProvider: BaseProvider,
addressManagerAddress: string,
signer?: Signer
): Promise<OptimismContracts> => {
Expand Down

0 comments on commit 7fb268f

Please sign in to comment.