Commit 3c2acd91 authored by Kelvin Fichter's avatar Kelvin Fichter Committed by smartcontracts

refactor: improve core-utils folder structure

Improves the folder structure within the core-utils to make it more
intuitive. core-utils is now split into three primary folders, "common",
"external", and "optimism". "common" includes TypeScript/JavaScript
utilities not necessarily meant to be used with any particular package
(like hex string utilities). "external" includes utilities that are
meant to be used in conjunction with some other particular piece of
tooling (ethers provider utilities, geth typings). "optimism" includes
any utilities that are specifically meant to be used in the context of
Optimism (like address aliasing utils, batch encoding utils).
parent 7de1a032
---
'@eth-optimism/core-utils': patch
---
Refactor folder structure of @eth-optimism/core-utils.
export * from './sequencer-batch'
import { ethers } from 'ethers' import { ethers } from 'ethers'
import { remove0x, add0x } from './common/hex-strings' import { remove0x, add0x } from './hex-strings'
/** /**
* Converts an ethers BigNumber into an equivalent Ethereum address representation. * Converts an ethers BigNumber into an equivalent Ethereum address representation.
......
/**
* Common JavaScript/TypeScript utilities
*/
export * from './basic-types'
export * from './bn'
export * from './hex-strings' export * from './hex-strings'
export * from './misc' export * from './misc'
export * from './test-utils' export * from './test-utils'
/**
* Utilities related to BCFG
*/
export * from './bcfg-types'
/**
* Utilities that extend or enhance the ethers.js library
*/
export * from './fallback-provider'
/**
* Utilities related to go-ethereum (Geth)
*/
export * from './geth-types'
export * from './geth' /**
* Utilities related to specific external projects
*/
export * from './bcfg' export * from './bcfg'
export * from './rollup' export * from './ethers'
export * from './basic' export * from './geth'
export * from './coders'
export * from './common' export * from './common'
export * from './watcher' export * from './external'
export * from './l2context' export * from './optimism'
export * from './types'
export * from './fees'
export * from './provider'
export * from './alias'
export * from './types'
export * from './bn'
import { ethers } from 'ethers' import { ethers } from 'ethers'
import { bnToAddress } from './bn' import { bnToAddress } from '../common'
// Constant representing the alias to apply to the msg.sender when a contract sends an L1 => L2 // Constant representing the alias to apply to the msg.sender when a contract sends an L1 => L2
// message. We need this aliasing scheme because a contract can be deployed to the same address // message. We need this aliasing scheme because a contract can be deployed to the same address
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
import { BigNumber } from 'ethers' import { BigNumber } from 'ethers'
import { remove0x } from './common' import { remove0x } from '../common'
const txDataZeroGas = 4 const txDataZeroGas = 4
const txDataNonZeroGasEIP2028 = 16 const txDataNonZeroGasEIP2028 = 16
......
/**
* Utils specifically related to Optimism.
*/
export * from './alias'
export * from './batch-encoding'
export * from './fees'
export * from './l2context'
export * from './rollup-types'
export * from './watcher'
import { expect } from './setup' import { expect } from './setup'
import { applyL1ToL2Alias, undoL1ToL2Alias } from '../src/alias' import { applyL1ToL2Alias, undoL1ToL2Alias } from '../src'
describe('address aliasing utils', () => { describe('address aliasing utils', () => {
describe('applyL1ToL2Alias', () => { describe('applyL1ToL2Alias', () => {
......
import * as fees from '../src/fees' import { zeroesAndOnes } from '../src'
describe('Fees', () => { describe('Fees', () => {
it('should count zeros and ones', () => { it('should count zeros and ones', () => {
...@@ -10,7 +10,7 @@ describe('Fees', () => { ...@@ -10,7 +10,7 @@ describe('Fees', () => {
] ]
for (const test of cases) { for (const test of cases) {
const [zeros, ones] = fees.zeroesAndOnes(test.input) const [zeros, ones] = zeroesAndOnes(test.input)
zeros.should.eq(test.zeros) zeros.should.eq(test.zeros)
ones.should.eq(test.ones) ones.should.eq(test.ones)
} }
......
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