diff --git a/.changeset/real-snails-allow.md b/.changeset/real-snails-allow.md new file mode 100644 index 0000000000000000000000000000000000000000..3d3622043963ffdf7ec4fc6a78f0151a4586e07a --- /dev/null +++ b/.changeset/real-snails-allow.md @@ -0,0 +1,6 @@ +--- +'@eth-optimism/core-utils': minor +'@eth-optimism/data-transport-layer': patch +--- + +removed unused functions from core-utils diff --git a/packages/core-utils/src/coders/sequencer-batch.ts b/packages/core-utils/src/coders/sequencer-batch.ts index 21340f3c39b16443f198975876f7ba4288cdef4b..15eb1245eb1951e4baf0776b4cc0813611979835 100644 --- a/packages/core-utils/src/coders/sequencer-batch.ts +++ b/packages/core-utils/src/coders/sequencer-batch.ts @@ -15,10 +15,6 @@ export interface AppendSequencerBatchParams { transactions: string[] // total_size_bytes[],total_size_bytes[] } -/********************** - * Internal Functions * - *********************/ - const APPEND_SEQUENCER_BATCH_METHOD_ID = 'appendSequencerBatch()' export const encodeAppendSequencerBatch = ( diff --git a/packages/core-utils/src/common/addresses.ts b/packages/core-utils/src/common/addresses.ts deleted file mode 100644 index e6a7329cba676256d626505b5d6d4188687252ac..0000000000000000000000000000000000000000 --- a/packages/core-utils/src/common/addresses.ts +++ /dev/null @@ -1,10 +0,0 @@ -/* Imports: External */ -import { ethers } from 'ethers' - -/* Imports: Internal */ -import { getRandomHexString } from './hex-strings' - -/* @returns a random Ethereum address as a string of 40 hex characters, normalized as a checksum address. */ -export const getRandomAddress = (): string => { - return ethers.utils.getAddress(getRandomHexString(20)) -} diff --git a/packages/core-utils/src/common/common.ts b/packages/core-utils/src/common/common.ts deleted file mode 100644 index df889eb2dfcbc20fa6ce50651bec21b847297a9b..0000000000000000000000000000000000000000 --- a/packages/core-utils/src/common/common.ts +++ /dev/null @@ -1,9 +0,0 @@ -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}`) - } -} diff --git a/packages/core-utils/src/common/hex-strings.ts b/packages/core-utils/src/common/hex-strings.ts index aab9e9ebca8009ddfe976c2437fa04ec6dc39b99..f51120f9f902f094c545a3049bbf9663d1474d58 100644 --- a/packages/core-utils/src/common/hex-strings.ts +++ b/packages/core-utils/src/common/hex-strings.ts @@ -27,16 +27,6 @@ export const add0x = (str: string): string => { return str.startsWith('0x') ? str : '0x' + str } -/** - * Returns whether or not the provided string is a hex string. - * - * @param str The string to test. - * @returns True if the provided string is a hex string, false otherwise. - */ -export const isHexString = (inp: any): boolean => { - return typeof inp === 'string' && inp.startsWith('0x') -} - /** * Casts a hex string to a buffer. * @@ -88,30 +78,5 @@ export const padHexString = (str: string, length: number): string => { } } -export const getLen = (pos: { start; end }) => (pos.end - pos.start) * 2 - export const encodeHex = (val: any, len: number) => remove0x(BigNumber.from(val).toHexString()).padStart(len, '0') - -export const toVerifiedBytes = (val: string, len: number) => { - val = remove0x(val) - if (val.length !== len) { - throw new Error('Invalid length!') - } - return val -} - -/** - * @param byteLength The length of the hex string in bytes - * @returns a random hex string of the specified byteLength (string length will be byteLength*2) - */ -export const getRandomHexString = (byteLength: number): string => { - return ( - '0x' + - [...Array(byteLength * 2)] - .map(() => { - return Math.floor(Math.random() * 16).toString(16) - }) - .join('') - ) -} diff --git a/packages/core-utils/src/common/index.ts b/packages/core-utils/src/common/index.ts index 762eb9bbc4c1e90256ba71189fcacbbb3905254e..251e67769960eebd9a09d153937a57641859f711 100644 --- a/packages/core-utils/src/common/index.ts +++ b/packages/core-utils/src/common/index.ts @@ -1,4 +1,2 @@ -export * from './addresses' export * from './hex-strings' export * from './misc' -export * from './common' diff --git a/packages/core-utils/src/fees.ts b/packages/core-utils/src/fees.ts index ec489e77e97f933b4a3675ece31bcf398f6c7f13..5c9013a7edfb2f18f7d54de10f5d4328260f6db6 100644 --- a/packages/core-utils/src/fees.ts +++ b/packages/core-utils/src/fees.ts @@ -5,14 +5,12 @@ import { BigNumber } from 'ethers' import { remove0x } from './common' -const hundredMillion = BigNumber.from(100_000_000) const feeScalar = 10_000_000 -export const TxGasPrice = BigNumber.from(feeScalar + feeScalar / 2) const txDataZeroGas = 4 const txDataNonZeroGasEIP2028 = 16 const overhead = 4200 + 200 * txDataNonZeroGasEIP2028 const tenThousand = BigNumber.from(10_000) - +export const TxGasPrice = BigNumber.from(feeScalar + feeScalar / 2) export interface EncodableL2GasLimit { data: Buffer | string l1GasPrice: BigNumber | number diff --git a/packages/core-utils/test/common/addresses.spec.ts b/packages/core-utils/test/common/addresses.spec.ts deleted file mode 100644 index df1b1bcd717c5fc635fc3466d80f8cb00bd29f04..0000000000000000000000000000000000000000 --- a/packages/core-utils/test/common/addresses.spec.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { expect } from '../setup' - -/* Imports: Internal */ -import { getRandomAddress } from '../../src' - -describe('getRandomAddress', () => { - const random = global.Math.random - - before(async () => { - global.Math.random = () => 0.5 - }) - - after(async () => { - global.Math.random = random - }) - - it('returns a random address string', () => { - expect(getRandomAddress()).to.equal('0x' + '88'.repeat(20)) - }) -}) diff --git a/packages/core-utils/test/common/hex-utils.spec.ts b/packages/core-utils/test/common/hex-utils.spec.ts index c91ceca9f207499bcb768113558cd3491ca5d858..1b7260e2cec48f770bafb93a19377ee179306bc9 100644 --- a/packages/core-utils/test/common/hex-utils.spec.ts +++ b/packages/core-utils/test/common/hex-utils.spec.ts @@ -2,23 +2,7 @@ import { expect } from '../setup' import { BigNumber } from 'ethers' /* Imports: Internal */ -import { getRandomHexString, toRpcHexString } from '../../src' - -describe('getRandomHexString', () => { - const random = global.Math.random - - before(async () => { - global.Math.random = () => 0.5 - }) - - after(async () => { - global.Math.random = random - }) - - it('returns a random address string of the specified length', () => { - expect(getRandomHexString(8)).to.equal('0x' + '88'.repeat(8)) - }) -}) +import { toRpcHexString } from '../../src' describe('toRpcHexString', () => { it('should parse 0', () => { diff --git a/packages/core-utils/test/fees/fees.spec.ts b/packages/core-utils/test/fees/fees.spec.ts index 3870092dfc573ec4327ce47153b51c9435a46ee8..d5c1debf1052cb4b30029471ac65aa9cc3c525a2 100644 --- a/packages/core-utils/test/fees/fees.spec.ts +++ b/packages/core-utils/test/fees/fees.spec.ts @@ -1,9 +1,8 @@ import { expect } from '../setup' import * as fees from '../../src/fees' -import { BigNumber, utils } from 'ethers' +import { utils } from 'ethers' const hundredBillion = 10 ** 11 -const million = 10 ** 6 describe('Fees', () => { it('should count zeros and ones', () => { diff --git a/packages/data-transport-layer/src/services/l1-ingestion/service.ts b/packages/data-transport-layer/src/services/l1-ingestion/service.ts index f4df71881f1466a1e6cf744d0f4ac84da73fd879..58e19ab484c827a48e670fc4d0b13bfa2e730216 100644 --- a/packages/data-transport-layer/src/services/l1-ingestion/service.ts +++ b/packages/data-transport-layer/src/services/l1-ingestion/service.ts @@ -1,5 +1,5 @@ /* Imports: External */ -import { fromHexString, EventArgsAddressSet } from '@eth-optimism/core-utils' +import { fromHexString } from '@eth-optimism/core-utils' import { BaseService, Metrics } from '@eth-optimism/common-ts' import { JsonRpcProvider } from '@ethersproject/providers' import { LevelUp } from 'levelup'