Commit 4878667a authored by Antonis Kogias's avatar Antonis Kogias Committed by smartcontracts

Deleted common.ts in data-transport-layer and replaced them from core-utils

parent 9784c462
---
'@eth-optimism/data-transport-layer': patch
---
Deletes common.ts in data-transport-layer. Uses core-utils.
/* Imports: External */
import { fromHexString, FallbackProvider } from '@eth-optimism/core-utils'
import {
fromHexString,
FallbackProvider,
sleep,
} from '@eth-optimism/core-utils'
import { BaseService, Metrics } from '@eth-optimism/common-ts'
import { TypedEvent } from '@eth-optimism/contracts/dist/types/common'
import { BaseProvider } from '@ethersproject/providers'
......@@ -15,7 +19,6 @@ import { MissingElementError } from './handlers/errors'
import { TransportDB } from '../../db/transport-db'
import {
OptimismContracts,
sleep,
loadOptimismContracts,
loadContract,
validators,
......
/* Imports: External */
import { BigNumber, ethers } from 'ethers'
import { serialize } from '@ethersproject/transactions'
import { padHexString } from '@eth-optimism/core-utils'
/* Imports: Internal */
import { TransportDB } from '../../../db/transport-db'
......@@ -9,7 +10,7 @@ import {
StateRootEntry,
TransactionEntry,
} from '../../../types'
import { padHexString, parseSignatureVParam } from '../../../utils'
import { parseSignatureVParam } from '../../../utils'
export const handleSequencerBlock = {
parseBlock: async (
......
/* Imports: External */
import { BaseService, Metrics } from '@eth-optimism/common-ts'
import { StaticJsonRpcProvider } from '@ethersproject/providers'
import { sleep, toRpcHexString } from '@eth-optimism/core-utils'
import { BigNumber } from 'ethers'
import { LevelUp } from 'levelup'
import axios from 'axios'
......@@ -10,7 +11,7 @@ import { Gauge } from 'prom-client'
/* Imports: Internal */
import { handleSequencerBlock } from './handlers/transaction'
import { TransportDB } from '../../db/transport-db'
import { sleep, toRpcHexString, validators } from '../../utils'
import { validators } from '../../utils'
import { L1DataTransportServiceOptions } from '../main/service'
interface L2IngestionMetrics {
......
import { toHexString } from '@eth-optimism/core-utils'
/**
* Basic timeout-based async sleep function.
*
* @param ms Number of milliseconds to sleep.
*/
export const sleep = async (ms: number): Promise<void> => {
return new Promise<void>((resolve) => {
setTimeout(resolve, ms)
})
}
export const assert = (condition: () => boolean, reason?: string) => {
try {
if (condition() === false) {
throw new Error(`Assertion failed: ${reason}`)
}
} catch (err) {
throw new Error(`Assertion failed: ${reason}\n${err}`)
}
}
export const toRpcHexString = (n: number): string => {
if (n === 0) {
return '0x0'
} else {
// prettier-ignore
return '0x' + toHexString(n).slice(2).replace(/^0+/, '')
}
}
export const padHexString = (str: string, length: number): string => {
if (str.length === 2 + length * 2) {
return str
} else {
return '0x' + str.slice(2).padStart(length * 2, '0')
}
}
export * from './common'
export * from './contracts'
export * from './validation'
export * from './eth-tx'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment